php mcrypt to javascript aes integration

栏目: PHP · 发布时间: 7年前

内容简介:来编码数据,使用AES-256-CBC和php mcrypt库进行解码,反之亦然.我知道javascript的问题本质以及任何人都看到密钥的事实,但我使用javascript作为非web环境的脚本工具 – 所以不要担心它.我找到了pidder
我正在尝试使用 javascript

来编码数据,使用AES-256-CBC和php mcrypt库进行解码,反之亦然.

我知道javascript的问题本质以及任何人都看到密钥的事实,但我使用javascript作为非web环境的脚本工具 – 所以不要担心它.

我找到了pidder https://sourceforge.net/projects/pidcrypt/

并使用演示页面加密了一些数据,然后试图通过 php 解密它,但是出了点问题,我似乎无法找到什么……我使用的是两端相同的密钥,一个32字节的字符串

任何指针将不胜感激

~~~

$encrypted = "string after pidder encryption";  

$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_256,'',MCRYPT_MODE_CBC,'');    

$iv_size = mcrypt_enc_get_iv_size($cipher);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);

mcrypt_generic_init($cipher, $key, $iv);


$encrypted = base64_decode($encrypted);

echo "after b64decode: " . $encrypted . "\n\n\n";

$encrypted = mdecrypt_generic($cipher, $encrypted);

echo "decrypt:" . $encrypted;

~~~


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Algorithms to Live By

Algorithms to Live By

Brian Christian、Tom Griffiths / Henry Holt and Co. / 2016-4-19 / USD 30.00

A fascinating exploration of how insights from computer algorithms can be applied to our everyday lives, helping to solve common decision-making problems and illuminate the workings of the human mind ......一起来看看 《Algorithms to Live By》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具