Answer the question
In order to leave comments, you need to log in
There is a node.js code snippet, you need to implement it in php (AES-256-CTR encryption). How?
task: to correctly generate a signature for an external api, as an example of generating a valid signature, there is this code on the node:
var encrypt = function(text, password) {
var cipher = crypto.createCipher('aes-256-ctr', password)
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex')
return crypted
}
$sign = bin2hex(openssl_encrypt($text, 'AES-256-CTR', $password,1,str_repeat('\0',8)));
Answer the question
In order to leave comments, you need to log in
Working but not native solution:
exec('openssl enc -aes-256-ctr -a -in string.txt -k your_password -nosalt -out openssl_out.txt');
echo bin2hex(base64_decode(file_get_contents('ssl_out.txt')));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question