蛋糕PHP如何外部生成其密码
CakePHP how to generate its password external
CakePHP 如何生成其外部密码
我习惯使用php,我有一个需要与CakePHP集成的应用程序。
基本上,我正在尝试创建一个登录表单,该表单可以使用与CakePHP相同的哈希和加密方法。
我研究了几个文件,如蛋糕PHP的安全组件和AuthComponent,这就是我得出的
$string = "demopassw0rd";
$type = null;
$salt = "mySALT";
$string = $salt . "demo1234";
$stringnew = sha1($string);
echo md5($stringnew);
echo " SPACES ";
$stringnew2 = bin2hex(mhash(MHASH_SHA256, $string));
echo md5($stringnew2);
//Below is the real code.
if ($salt) {
if (is_string($salt)) {
$string = $salt . $string;
} else {
$string = $salt . $string;
}
}
if (empty($type)) {
$type = $hashType;
}
$type = strtolower($type);
if ($type == 'sha1' || $type == null) {
if (function_exists('sha1')) {
$return = sha1($string);
return $return;
}
$type = 'sha256';
}
if ($type == 'sha256' && function_exists('mhash')) {
return bin2hex(mhash(MHASH_SHA256, $string));
}
使用上述从蛋糕 php 中提取的方法,我无法检索存储在 mysql 中的相同密码哈希。
我正在尝试创建一个哈希方法,以便我可以创建另一个不是 cakephp 框架的登录表单,并且能够使用与驻留在同一服务器中的 cake php 软件相同的登录表。
* The level of CakePHP security.
*/
Configure::write('Security.level', 'medium');
/**
* A random string used in security hashing methods.
*/
Configure::write('Security.salt', 'mySALT');
/**
* A random numeric string (digits only) used to encrypt/decrypt strings.
*/
Configure::write('Security.cipherSeed', '65986349865349087509054352724');
我如何使用上面的配置来制作我自己的哈希方法,该方法可以将我的输入字符串哈希为与我使用 cakephp 存储在 mysql 中的内容相同
我为上述配置解释的蛋糕php哈希方法是
首先
$salt . $string to form a $string value
then sha1($string) and then md5($string)
or bin2hex with the sha264 ($string) and then md5(string)
但是我都尝试过但都未能获得与蛋糕 php 相同的哈希
另一种选择可能是在您的蛋糕应用程序中调用网络服务。 考虑到这一点,您可以从任何语言或应用程序调用它...... 有了这个,你正在使用蛋糕的机制,就像马克说的"使用现有类",但以另一种形式......
相关文章:
- 调整窗口大小时,可拖动的对象会出现在容器外部
- HTML表单提交时未执行外部函数
- 通过在Dojo mobile ViewController.openExternalView中动态更改打开同一外部视图的
- 使用html中的外部javascript进行数据验证
- 将变量传递给外部Javascript
- 使用javascript在Flash中加载外部图像
- Firebase2(Firebase.google.com)推送通知-从外部管理
- 如何更改reactjs中外部/独立组件的状态或属性
- 如何使用密码检测网络中的状态连接
- Meteor忘记了密码的实现
- 如何从外部页面激活非默认引导选项卡
- 如何在运行时在angular 2中加载外部js脚本
- JavaScript-在手机上不工作的情况下,在外部单击时隐藏元素
- 单击元素外部时进行JQuery
- 我的外部js文件无法加载
- 拆下外部分配器
- 使用密码对话框Javascript请求帮助
- 什么'在webpack外部设置中,reactDom和reactDom不同
- 将依赖外部库的UMD模块与browserfy捆绑在一起
- 蛋糕PHP如何外部生成其密码