php - 如何使用Python进行Rijndael方式的加密解密?
高洛峰
高洛峰 2017-04-10 14:31:26
0
0
338

以下是使用PHP进行Rijndael方式加密的例子:

function encrypt($data) { return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256 ,'oqufXQ(?bc=6_hR2I3sMZChDpb6dDlw4', $data , MCRYPT_MODE_CBC, utf8_encode('fOaiIOkD8*9Xeu_s4_bb87Ox_UG+D9GA'))); }

我曾找到这个代码,里面的答案的确可行,但如何自定义iv?(即utf8_encode('fOaiIOkD8*9Xeu_s4_bb87Ox_UG+D9GA')
另,block_sizekey_sizeiv_size均需要为32(字节)。


编译mcrypt.c,GCC提示错误如下:

mcrypt.c: In function 'initmcrypt': mcrypt.c:1714:2: error: incompatible type for argument 1 of 'PyString_FromString ' In file included from C:\Python27\include/Python.h:94:0, from mcrypt.c:24: C:\Python27\include/stringobject.h:63:24: note: expected 'const char *' but argu ment is of type 'double' error: command 'gcc' failed with exit status 1
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all (0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!