The text of this article is not in this database — only its details are. Read it on the old site: Encrypt in JavaScript and Decrypt in C# With AES Algorithm
49 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.

hill allPosted Oct 9, 2021, 12:35 PM
Hi, will you have code for Encrypt in JavaScript and Decrypt in VB With AES Algorithm
Saurabh SoniPosted Jul 24, 2020, 2:23 PM
Sir, What about decryption on the client-side. I need to decode encoded string (from backend) into js response method.
Amman VermaPosted Jul 10, 2020, 6:15 AM
Hi, will you have code for Encrypt in C# and Decrypt in JavaScript(html page) With AES Algorithm
Aniket NarvankarPosted Apr 29, 2020, 9:31 PM
I am getting key error,what key should I use,not understanding this
Tamil GroupPosted Apr 17, 2020, 12:43 PM
Hi Sir, Small doubt, Key and iv is mentioned "8080808080808080" in javascript. After run a page, if anyone go to browser and click "Source", they can easily know the key and iv right? then can decrypt using this right? then there is no security right? please suggest
desai balvantPosted Apr 8, 2020, 12:43 AM
Its working fine but how to use 256 encryption
Biju KrishnanPosted Mar 30, 2020, 7:16 AM
I tried this with this example.But I got exception "Padding is inavalid and cannot be removed"
Ravi KumarPosted Mar 5, 2020, 2:57 AM
I have changed the "8080808080808080" to "7676876876786234" but encrypt string of same input value is same .. Here no any sense of use key because after change of key ... Same output. I am not like this process
Dinesh PeriyasamyPosted Aug 21, 2019, 9:54 PM
Whats the use encryption on client side, we can decrypt this password in client side because we know encryption logic and keys.
Sanjay YadavPosted Jul 24, 2019, 1:29 AM
Very helpful for understanding the implementation of AES with client side and access with server side.
Mega AnaskaPosted Jun 19, 2019, 1:20 AM
Why File is not Found ?
Pratik GohilPosted Jun 11, 2018, 3:54 AM
Why String with curly brace do not decrypt ??
Gopi KrishnanPosted May 30, 2018, 2:57 AM
I got error like "Invalid length for a Base-64 char array or string." plz give the solution
it iwantPosted May 10, 2018, 10:48 PM
Hi, Thanks for your share, but i'm wondering that how to secure when the thief know keybytes and iv, and he has this script C#, can you clear problem for me? thank you.
Satriyo PrakosoPosted May 7, 2018, 5:39 AM
It works like a charm. thanks mate !
Mohan KamargiriPosted Mar 28, 2018, 1:37 AM
I'm unable to find aes.js file. Can anyone please provide that file? I'm getting page not found when browse the URL to get aes.js file
Karayanni KarayanniPosted Feb 21, 2018, 9:25 AM
I Have this JS file that encypts how to decrypt in C# -------------- function encrypt(text) { var hexKey = 'E8E9277F7A2696F29EDAAE6EC29F659F'; var key = aesjs.utils.hex.toBytes(hexKey); while ((text.length % 32) !== 0) { text += ' '; } var textBytes = aesjs.utils.utf8.toBytes(text); var aesEcb = new aesjs.ModeOfOperation.ecb(key); var encryptedBytes = aesEcb.encrypt(textBytes); // To print or store the binary data, you may convert it to hex var encryptedHex = aesjs.utils.hex.fromBytes(encryptedBytes); return encryptedHex }
Karayanni KarayanniPosted Feb 21, 2018, 9:23 AM
Please Help, I have javascript code that encrypt
Sanjay ShekhawatPosted Jan 10, 2018, 4:51 AM
Working perfectly, thanks :)
kim hsuPosted Oct 25, 2017, 10:55 PM
Why needs "string.Format(decriptedFromJavascript); "
Shruthi SreedharPosted Sep 13, 2017, 6:09 AM
I am getting an error while decrypting using c# : 'padding is invalid and cannot be removed'. Please help.
Eric WijayaPosted Sep 12, 2017, 4:02 AM
Thanks a lot, really really appreciate
lari johnPosted Jul 18, 2017, 4:03 AM
Very helpful and implemented in my project.
Mrinal JhaPosted Jun 27, 2017, 3:50 AM
How to decrypt the cipher text using this library in javascript?Thanks
saikumar GodaluPosted Jun 7, 2017, 2:27 PM
To Decrypt on client side : var decryptedData = CryptoJS.AES.decrypt(encrypted, key, { keySize: 128 / 8, iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 } ); console.log('Original Text : '+decryptedData.toString(CryptoJS.enc.Utf8)) // outputs "Hello world"
saikumar GodaluPosted Jun 7, 2017, 2:26 PM
To Encrypt in C# : AESEncrytDecry.EncryptStringAES("Hello world");
raviPosted May 18, 2017, 9:48 AM
Good. encryption in c# and decryption in javascript is available ??
Milap ShahPosted Apr 12, 2017, 7:55 AM
How can I download this JS?
Milap ShahPosted Apr 12, 2017, 7:55 AM
Http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js Not working..
Tabarak HussainPosted Mar 23, 2017, 8:33 AM
Excellent work, very very thax for help
Kham DucPosted Dec 1, 2016, 1:57 AM
System.Security.Cryptography.CryptographicException: Length of the data to decrypt is invalid.
Virbhadrasinh GohilPosted Sep 28, 2016, 6:10 AM
This is the best example and one of the highly secured way of client-side encryption.Thanks for the best stuff.
Saineshwar BageriPosted Jun 22, 2016, 8:29 AM
Please check your Script reference and see browser console for errors
Ratish NairPosted Jun 22, 2016, 7:51 AM
var encryptedlogin = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(txtUserName), key, Is giving me an error of undefined when oublished it on the server
Ratish NairPosted Jun 22, 2016, 7:51 AM
var encryptedlogin = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(txtUserName), key,
vighnesh sawantPosted Apr 12, 2016, 1:27 PM
how to see the decrypted value ??
Deepak TiwariPosted Feb 17, 2016, 7:53 AM
Is vice versa available? Mean we can encrypt in C# and decrypt using CryptoJS
Robin LiPosted Dec 10, 2015, 1:18 AM
great example, thanks a lot ^_^
Naresh YadavPosted Sep 18, 2015, 6:20 AM
Hey thankyou so much for the valuable articale sharing. its working !!
Yashwanth MuthineniPosted Aug 27, 2015, 3:17 AM
Nice Share
Ray LevronPosted Jul 16, 2015, 4:22 PM
Nevermind. I got it working. I was able to use this code sample successfully in our app. Thanks for this
Ray LevronPosted Jul 15, 2015, 12:49 PM
What do I do to get different encrypted data? If I pass "1830" or "1840", I get the same encrypted data
ashok kumarPosted Jul 8, 2015, 8:38 AM
How to prevent from Man-in-the-Middle attack?
Dinesh BeniwalPosted Mar 1, 2015, 12:37 AM
Congrats Saineshwar Bageri Article of the day on ASP.NET
Saineshwar BageriPosted Feb 26, 2015, 11:26 AM
its not MD5 Narendra Bisht sir it will just Encrypt in JavaScript and Decrypt in C#
Narendra BishtPosted Feb 26, 2015, 6:02 AM
Hi..everytime is generating the same password for all users...
Saineshwar BageriPosted Jan 19, 2015, 12:39 AM
thanks vithal sir
Vithal WadjePosted Jan 18, 2015, 2:53 PM
nice keep it up