Encrypting a string in Javascript and Decrypting in C#

I recently had to figure out a way to encrypt a string sent from a JavaScript app client and then receive that string on an ASP.NET server and subsequently decrypt it. Below is first the client-side JavaScript code, and then the server-side C# code. The key and iv have to be the same on both client and server and should be concealed from any 3rd party if possible. I’ve used a random string “8056483646328763” as both here, but please change it if you use this code. Make sure the size arguments match the size of your key string, so 128/8 (=16) in this case. This…



Cognitive Science and IT

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store