1

I want encryption and decryption of a Uint8Array for that i have downloaded CryptoJS library from this link.

I have tested aes cipher algorithm on a dummy string its working fine.

Now i want it to implement it on Uint8Array. This array is holding a video file data.

Since the encryption and decryption works on a string, i have to convert it to a string for that i have referenced this question posted on the stackoverflow click here

Code for encryption is :

var encrypted = CryptoJS.AES.encrypt(String.fromCharCode.apply(null, uInt8Array), "test");

But when i ran the code following error is coming:

 Uncaught RangeError: Maximum call stack size exceeded 

How do i make it working?

1 Answer 1

2

That error is due the String.fromCharCode.apply(null, uInt8Array) part, CryptoJS is never called.

Note that full syntax of fromCharCode is String.fromCharCode(n1, n2, ..., nX), so all elements of the given buffer must be moved to the stack in order to apply the function.

You must be using a very big buffer, a video file you said, so that must be the reason you got a stackoverflow error.

Try to use a `CryptoJS.lib.WordArray' instead, as described here:

http://groups.google.com/group/crypto-js/browse_thread/thread/4ce6fddad709954d?pli=1

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

3 Comments

Thanks juan for replying. Yeh this buffer contains video file data (v11.webm 10.5 MB). How can i apply encryption/decryption?
@PankajKhurana I'm not a CryptoJS user, just pointing you in the right direction. Anyway, a quick look at library documentation reveals that "the cipher algorithms accept either strings or instances of CryptoJS.lib.WordArray". I think you could follow from there, I would do it.
i had a look at it but could not find any relevant info. can you please suggest me some other library which can get the job done?

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.