TransWikia.com

How Can replicate this cryptojs encrypt with PHP?

Stack Overflow Asked on November 12, 2021

I have this encrypt function in Typescript.

encrypt( text, password) {
let response = '';
let text= btoa(text);

const keyBytes = CryptoJS.PBKDF2(password, this.KEY_COMPLEMENTARY, { keySize: 48 / 4, iterations: 1000 });
const key = new CryptoJS.lib.WordArray.init(keyBytes.words, 32);
const iV = new CryptoJS.lib.WordArray.init(keyBytes.words.splice(32 / 4), 16);
const data = CryptoJS.enc.Utf16LE.parse(text);
const encrypted = CryptoJS.AES.encrypt(data, key, { iv: iV });

response = encrypted.toString();

return response;}

Is it possible to program this encryption in PHP?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP