0

I tried to find examples relate to CryptoJS decrypt in PHP but failed with me. In Nodejs, i use these code for decrypt:

let decrypted = CryptoJS.AES.decrypt(encrypted, key).toString(CryptoJS.enc.Utf8)

How can I decrypt the same as above in PHP ?

This is example for encrypted and key string:

encrypted: U2FsdGVkX19K5LVvRXaJ9BIIUZexwZLXPbYRSLlN53mXahlwvEtEEPGLnzr9lWF5A97msFXZEg/tjCCv0QNfV/Pv5l6tzMmLXH4TthEDOlu7QDOxB529fDEfkOvBPnBpPXd+SijAUptLhGqEXhPbuPQLYdAwVdjPO+TnH43q6YOT7C9ClR5sf7+RKsVHzG6NdGszB8JUuhpvFYPOigUXQbD/YnAbk3hWn+odgvVIiJSSO0KWodVm7Dczr41nBO2mtJRe7hstSM93t7zwztsmXQ==

key: 0c135f43cff3e8a55a0ddb001f6293c5

Thanks.

Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
Mr.Kun
  • 1
  • Can you help me decrypt with above string and key ? I tried but failed :-( – Mr.Kun Jul 05 '19 at 17:39
  • What have you tried so far, and how did it fail? – Mark Jul 05 '19 at 17:53
  • Hi. I'm tried some example in these post: https://stackoverflow.com/questions/41222162/encrypt-in-php-openssl-and-decrypt-in-javascript-cryptojs https://stackoverflow.com/questions/30781402/encrypting-with-php-decrypting-with-cryptojs https://programmer.help/blogs/5c2f928117a41.html – Mr.Kun Jul 05 '19 at 18:31
  • https://stackoverflow.com/help/how-to-ask – Mark Jul 05 '19 at 18:51
  • @Mark It's probably best not to recommend mcrypt for new code, as it was [removed in PHP 7.2](https://www.php.net/manual/en/intro.mcrypt.php) because nobody was maintaining it. The better recommendation would be [Sodium](https://www.php.net/manual/en/book.sodium.php) which is shipped with PHP 7.2 and [available as a PECL extension](https://pecl.php.net/package/libsodium) for earlier versions. – IMSoP Jul 19 '19 at 13:49

0 Answers0