mcrypt_encrypt为同一输入提供不同的结果? [英] mcrypt_encrypt giving different results for same input?

查看:73
本文介绍了mcrypt_encrypt为同一输入提供不同的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在使用PHP 4.4.4。使用

mcrypt_encrypt函数发生了奇怪的事情。我正在尝试加密一串数据(用于

密码存储):


$ enc = mcrypt_encrypt(MCRYPT_XTEA,ENCRYPTION_KEY,$ p_str,
MCRYPT_MODE_ECB,$ iv);


然后我试图通过加密输入的密码

然后比较它来登录保存的密码。然而,尽管每次通话都是

,输入是相同的,


MCRYPT_XTEA =" xtea";

ENCRYPTION_KEY =" sdlk2kcow8doq92k";

$ p_str =" demo";

MCRYPT_MODE_ECB =" ecb";

$ iv = jX%uk?* =" ;;


在一次通话中我得到加密的字符串,?;jé?? G·而在另一个

电话,我得到?34Avy?。什么给了?


谢谢, - Dave

Hi,

I''m using PHP 4.4.4. An odd thing is happening with the
mcrypt_encrypt function. I am trying to encrypt a string of data (for
password storage):

$enc = mcrypt_encrypt(MCRYPT_XTEA, ENCRYPTION_KEY, $p_str,
MCRYPT_MODE_ECB, $iv);

and then I''m trying to log in later by encrypting the entered password
and comparing it to the saved password. However, despite the fact
that for each call, the inputs are the same,

MCRYPT_XTEA = "xtea";
ENCRYPTION_KEY = "sdlk2kcow8doq92k";
$p_str = "demo";
MCRYPT_MODE_ECB = "ecb";
$iv = "jX%uk?*=";

on one call I get the encrypted string, "?;jé??G·" and on the other
call, I get "?34Avy?". What gives?

Thanks, - Dave

推荐答案

enc = mcrypt_encrypt(MCRYPT_XTEA, ENCRYPTION_KEY,
enc = mcrypt_encrypt(MCRYPT_XTEA, ENCRYPTION_KEY,


p_str,

MCRYPT_MODE_ECB,
p_str,
MCRYPT_MODE_ECB,


iv);


然后我试着通过加密输入的密码

并将其与保存的密码进行比较来登录。然而,尽管每次通话都是

,输入是相同的,


MCRYPT_XTEA =" xtea";

ENCRYPTION_KEY =" sdlk2kcow8doq92k" ;;
iv);

and then I''m trying to log in later by encrypting the entered password
and comparing it to the saved password. However, despite the fact
that for each call, the inputs are the same,

MCRYPT_XTEA = "xtea";
ENCRYPTION_KEY = "sdlk2kcow8doq92k";


这篇关于mcrypt_encrypt为同一输入提供不同的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆