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?