CakePHP如何在外部生成其密码

问题描述 投票:0回答:1

CakePHP如何在外部生成其密码

我习惯使用php,我有一个需要与CakePHP集成的应用程序。

基本上我正在尝试创建一个可以使用CakePHP的相同哈希和加密方法的登录表单。

我查看几个文件,如CakeComponent和蛋糕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));
                }

使用从cake 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中一样

我为上面的配置解释了cake 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相同的哈希值

javascript php mysql cakephp hash
1个回答
1
投票

另一个选择可能是在你的蛋糕应用程序中调用web服务..考虑到你可以从任何语言或应用程序调用它...你正在使用蛋糕的机制像马克说“使用现有的类”但在另一种形式......

© www.soinside.com 2019 - 2024. All rights reserved.