0

I am having some hard time figuring out how to convert the following code to PHP;

const envelope = JSON.stringify({ v: value, a: Cryptiles.randomString(2) });
const cipher = Crypto.createCipher('aes256', key);

let enc = cipher.update(envelope, 'utf8', 'binary');
enc += cipher.final('binary');

return (new Buffer(enc, 'binary')).toString('base64').replace(/\+/g, '-').replace(/\//g, ':').replace(/\=/g, '');

Any thoughts?

robinvdvleuten
  • 1,462
  • 1
  • 16
  • 18
  • 1
    You'll need an EVP_BytesToKey implementation like [this one](http://stackoverflow.com/a/27678978/1816580). Note that Stack Overflow is not a code translation service. – Artjom B. Oct 15 '16 at 11:42
  • @ArtjomB. thanks for the response! I didn't want to have it completely translated, just a small clue into the good direction :) I'll look into your given implementation, thanks! – robinvdvleuten Oct 15 '16 at 17:33

0 Answers0