运行时:
var_dump(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, '12345', '1abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz', MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
var_dump(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, '12345', '2abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz', MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
var_dump(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, '12345', '3abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz', MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
var_dump(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, '12345', '4abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz', MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
var_dump(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, '12345', '5abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz', MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
其结果是:
string 'X9VFmBzVWwUSoKPtE0VoEYxGkAPwVkUDQfQwF0wPDAVxedrGWE4oMCPBAF7FRBMoQsSUFwHhpknj/fHQqgQVPw==' (length=88)
string 'T/yn6lkyB73cEs57K2pUVNhFk2tDX02CbnBIU2c2I2VxedrGWE4oMCPBAF7FRBMoQsSUFwHhpknj/fHQqgQVPw==' (length=88)
string 'WysJWSV2k5gyYoQ4+hF0Uh2JqMJ6pTC8lcrgs1jmSklxedrGWE4oMCPBAF7FRBMoQsSUFwHhpknj/fHQqgQVPw==' (length=88)
string 'fMsJByfrZBYoQIgL/g+3i6jOPiaHh2Jf0vV59g1w1ZVxedrGWE4oMCPBAF7FRBMoQsSUFwHhpknj/fHQqgQVPw==' (length=88)
string 'Mw0AlrcC5v3v6swEg+wT+uTHf8MNrxdprD9GCpOe/45xedrGWE4oMCPBAF7FRBMoQsSUFwHhpknj/fHQqgQVPw==' (length=88)
注意字符串是如何以相同的字符集结尾的?
这应该发生吗?
我会认为因为数据不同,我每次都在创建一个新的初始化向量,这会导致完全不同的输出。
考虑到数据的微小变化,是否有另一种好的算法可以产生完全不同的输出?