0

I am having issue with CryptoJS.

I tried to encrypt the a string but it is giving the different output.

String: "test message" Key: "123456"

This is the testing code I tried to run

<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
<script>
   var encrypted = CryptoJS.AES.encrypt("test message", "123456");


   alert(encrypted);              //U2FsdGVkX19Nf4gjPS3MUcbKBD10P/Ty/4EwUF1PMhc=
</script>

and it returned the output U2FsdGVkX19Nf4gjPS3MUcbKBD10P/Ty/4EwUF1PMhc=

But in this website http://aesencryption.net/ I am getting fulfuBaIGS0AqxwyXoPCgw== as the result.

How do I use CryptoJS to generate the encrypted output as fulfuBaIGS0AqxwyXoPCgw==?

1
  • "123456" is not a valid key for AES. It must be either 16, 24 or 32 bytes long. How is the actual key derived from that password? What mode of operation is used by default on that site? Commented Aug 12, 2015 at 6:17

1 Answer 1

1

Those sites are bad, because they don't tell you what actually happens when you encrypt something. The two example codes below the online-encryption are different and don't produce the same thing as the online-encryption.

It seems this answer provides a working code in C# for that site. If this is true, then you can't reproduce this in CryptoJS, because CryptoJS only supports AES, whereas that example C# code uses Rijndael (note the block size of 256 bit).

AES is only defined for a fixed block size of 128 bit, but Rijndael supports 128, 192 and 256 bit block sizes. Both support key sizes of 128, 192 and 256 bit. CryptoJS actually implements only AES, but that site does not use AES despite its name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.