Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to decryption it with php? #81

Open
design365 opened this issue Jun 4, 2019 · 2 comments
Open

how to decryption it with php? #81

design365 opened this issue Jun 4, 2019 · 2 comments

Comments

@design365
Copy link

thanks for your work. but i want to decryption use php , how to do that?
and the aes-js password is byte array, but the php aes decryption's password is string。
how to do decryption?

@jusme
Copy link

jusme commented Aug 11, 2020

js 加密代码

key=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2];
counter=new aesjs.Counter(1);//默认是1
counter_key=counter._counter;//结果是[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
var aesCtr = new aesjs.ModeOfOperation.ctr(keys,counter);

php 解密代码

function bytes2String($bytes){
		$hex='';
		foreach($bytes as $byte){
			$one=dechex($byte);
			if(strlen($one)=='1'){
				$one='0'.$one;
			}
			$hex.=$one;
		}
		$string=hex2bin($hex);
		return $string;
}
$key=bytes2String([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2]);
$iv=bytes2String([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]);
$de_data=openssl_decrypt($data,'aes-128-ctr',$key,OPENSSL_RAW_DATA,$iv);

@ashvin27
Copy link

ashvin27 commented Sep 9, 2020

It is not working correctly. Please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants