admin管理员组

文章数量:1410682

I am using CryptoJS and I keep getting Uncaught TypeError. Basically, when I try to send the message an encrypt it, that is when I end up getting the error.

The error I am getting is within the cryptoJS package. Line 256 starts at var encrypted = CryptoJS.AES.encrypt(myString, myPassword);

I am assuming the issue is within the piece of code I have listed below, or there it is when I have been importing the package.

    var myString = messageInput.value;
    var myPassword = 11111;
    var encrypted = CryptoJS.AES.encrypt(myString, myPassword);

I am using CryptoJS and I keep getting Uncaught TypeError. Basically, when I try to send the message an encrypt it, that is when I end up getting the error.

The error I am getting is within the cryptoJS package. Line 256 starts at var encrypted = CryptoJS.AES.encrypt(myString, myPassword);

I am assuming the issue is within the piece of code I have listed below, or there it is when I have been importing the package.

    var myString = messageInput.value;
    var myPassword = 11111;
    var encrypted = CryptoJS.AES.encrypt(myString, myPassword);
Share edited Jun 22, 2018 at 2:54 Tibrogargan 4,6133 gold badges20 silver badges40 bronze badges asked Jun 22, 2018 at 2:18 Zubair AmjadZubair Amjad 7711 gold badge13 silver badges30 bronze badges 4
  • This code is not runnable as-is and you don't explain where you're getting the error. How exactly do you expect to get help with this? Please provide an minimal reproducible example – Tibrogargan Commented Jun 22, 2018 at 2:25
  • 2 try var myPassword = "11111"; – Jaromanda X Commented Jun 22, 2018 at 2:33
  • 1 Your plain text must be a string, not number. – Justinus Hermawan Commented Jun 22, 2018 at 2:38
  • Ahhhhh thank you it worked! I changed it to a string and its good to go! – Zubair Amjad Commented Jun 22, 2018 at 2:46
Add a ment  | 

1 Answer 1

Reset to default 4

Answer written from ments in OP.

Password be a string not a number. Rather than entering "11111" to test try "testpassword".

本文标签: javascriptUncaught TypeError Cannot read property 39039 of undefined CryptoJSStack Overflow