在本机中使用 codeigniter 库 Php 代码解密不起作用
Using codeigniter library in a native Php Code decrypt not working
来自新手用户的愚蠢问题。希望一切都好,我有一个问题。有许多 codeiginter 用户认为 codeigniter 在 php 编码时是最好的。我不怪他们,完全尊重他们的观点。一段时间以来,我一直是本地 Php 程序员,我只是想问问是否可以为我的本地 Php 项目使用 codeigniter 库。
我试过研究,但我想实际上没有人通过网络尝试过,所以我问这个。
我实际上是在尝试为我的 Pure php 使用 code igniter 的加密库。
有办法吗?
这是@barudo 告诉我的
<?php
include_once("enryption.php");
$key = '5fea190fb9cdbfdb7e2b69276df4c544';
function log_message($message)
{
error_log($message);
}
function config_item($what)
{
//just a placeholder...
}
$cipher = new CI_Encryption();
$cipher->initialize(
[
'driver'=>'openssl',
'key' => $key
]
);
$plaintext = 'bd410a21c2498e83109224b38f80743b83eafcb321c7ab56e027fb84ab76708b3797ad320d011520e9811aadc67c7d13ccf9bfb45e91d757004b25efc9717266qTmIbwsXDpDtzMbQur4+KwWt7zlmvTrq8B19rDMNmR4=';
//$ciphertext = $cipher->encrypt($plaintext);
//echo 'ciphertext: ' . $ciphertext . "\n"."</br>";
echo 'plaintext: ' . $cipher->decrypt($plaintext) . "\n";
?>
谢谢。
至于php加密,有多种加密方式可供选择。所以不要将自己局限于 CI 的图书馆。例如:http://php.net/manual/en/function.mcrypt-encrypt.php
但是关于您的问题,CI 是根据 MIT 许可证发布的,但有以下限制:
/**
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
除上述情况外,您可以自由采取任何措施。
关于使用图书馆:
您可以在此处复制库:https://raw.githubusercontent.com/bcit-ci/CodeIgniter/develop/system/libraries/Encryption.php
另存为 Enryption.php 然后创建另一个 php 文件:
include_once('Encryption.php');
$key = 'ASDFJGARLKERKL';
function log_message($message)
{
error_log($message);
}
function config_item($what)
{
//just a placeholder...
}
$cipher = new CI_Encryption();
$cipher->initialize(
[
'driver'=>'openssl',
'key' => $key
]
);
$plaintext = 'The quick brown fox';
$ciphertext = $cipher->encrypt($plaintext);
echo 'ciphertext: ' . $ciphertext . "\n";
echo 'plaintext: ' . $cipher->decrypt($ciphertext) . "\n";
来自新手用户的愚蠢问题。希望一切都好,我有一个问题。有许多 codeiginter 用户认为 codeigniter 在 php 编码时是最好的。我不怪他们,完全尊重他们的观点。一段时间以来,我一直是本地 Php 程序员,我只是想问问是否可以为我的本地 Php 项目使用 codeigniter 库。
我试过研究,但我想实际上没有人通过网络尝试过,所以我问这个。
我实际上是在尝试为我的 Pure php 使用 code igniter 的加密库。
有办法吗?
这是@barudo 告诉我的
<?php
include_once("enryption.php");
$key = '5fea190fb9cdbfdb7e2b69276df4c544';
function log_message($message)
{
error_log($message);
}
function config_item($what)
{
//just a placeholder...
}
$cipher = new CI_Encryption();
$cipher->initialize(
[
'driver'=>'openssl',
'key' => $key
]
);
$plaintext = 'bd410a21c2498e83109224b38f80743b83eafcb321c7ab56e027fb84ab76708b3797ad320d011520e9811aadc67c7d13ccf9bfb45e91d757004b25efc9717266qTmIbwsXDpDtzMbQur4+KwWt7zlmvTrq8B19rDMNmR4=';
//$ciphertext = $cipher->encrypt($plaintext);
//echo 'ciphertext: ' . $ciphertext . "\n"."</br>";
echo 'plaintext: ' . $cipher->decrypt($plaintext) . "\n";
?>
谢谢。
至于php加密,有多种加密方式可供选择。所以不要将自己局限于 CI 的图书馆。例如:http://php.net/manual/en/function.mcrypt-encrypt.php
但是关于您的问题,CI 是根据 MIT 许可证发布的,但有以下限制:
/**
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
除上述情况外,您可以自由采取任何措施。
关于使用图书馆:
您可以在此处复制库:https://raw.githubusercontent.com/bcit-ci/CodeIgniter/develop/system/libraries/Encryption.php
另存为 Enryption.php 然后创建另一个 php 文件:
include_once('Encryption.php');
$key = 'ASDFJGARLKERKL';
function log_message($message)
{
error_log($message);
}
function config_item($what)
{
//just a placeholder...
}
$cipher = new CI_Encryption();
$cipher->initialize(
[
'driver'=>'openssl',
'key' => $key
]
);
$plaintext = 'The quick brown fox';
$ciphertext = $cipher->encrypt($plaintext);
echo 'ciphertext: ' . $ciphertext . "\n";
echo 'plaintext: ' . $cipher->decrypt($ciphertext) . "\n";