簡體   English   中英

php 中的加密和 angular 中使用加密 JS 的 AES 解密

[英]Encryption in php and AES decryption in angular using crypto JS

這是我在 PHP 中的以下加密和解密,它工作正常,但我需要在 angular 7 中解密相同的東西,

Encryption in php using aes-256-cbc by following method
$this->data ="plaintext";
$this->
openssl_encrypt("plaintext", "aes-256-cbc", "1234567890",0,"1234567890")

但我嘗試使用 crypto-js 但它返回空值,

CryptoJS.AES.decrypt("ciphertext","1234567890".toString(CryptoJS.enc.Utf8);

提出任何想法。

我的目標是加密 php 中的字符串並解密 angular 中的值

試試下面的代碼:

const configuration = {
  keySize: 128 / 8,
  iv: CryptoJS.enc.Utf8.parse('<your initialization vector>'),
  mode: CryptoJS.mode.CBC
};

CryptoJS.AES.decrypt("ciphertext", "<your encryption key>", configuration).toString(CryptoJS.enc.Utf8);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM