brix / crypto-js

JavaScript library of crypto standards.
Other
15.82k stars 2.39k forks source link

Property 'concat' does not exist on type 'LibWordArray' #325

Open kenliten opened 3 years ago

kenliten commented 3 years ago
import * as CryptoJS from 'crypto-js';

encryptSecretKey = "mySecretKeyHere";

encryptData (msg) {
var keySize = 256;

var salt = CryptoJS.lib.WordArray.random(16); 

var key = CryptoJS.PBKDF2(this.encryptSecretKey, salt, {
keySize: keySize/32,
iterations: 100
}); 

var iv = CryptoJS.lib.WordArray.random(128/8);

var encrypted = CryptoJS.AES.encrypt(msg, key, {
iv: iv,
padding: CryptoJS.pad.Pkcs7,
mode: CryptoJS.mode.CBC
}); 

var result =CryptoJS.enc.Base64.stringify(salt.concat(iv).concat(encrypted.ciphertext));

return result;
}

Running this code, I get the error Property 'concat' does not exist on type 'LibWordArray'

TangTang23333 commented 1 year ago

Hi Kenliten,

Did you get this error fixed? I got the same error. I am thinking about converting wordArray to string and then use string.concat. How did you fix the above error?

Thanks.

TangTang

kenliten commented 1 year ago

Hello TangTang. I don't even remember what's the project I was working on when got posted this issue. Sorry.