Create a CryptoJS AES password encryptor to decrypt in .NET


Jamie Barker

I'm trying to create encryption/decryption that will work between server/client. I use CryptoJS on the client side and ASP.Net (VB.Net) on the server side. The server side is used in many places so it can't be changed, so CryptoJS needs to work around what .NET does. I can't get my CryptoJS to mimic .NET 100%.

FYI, .NET code cannot be changed, JS must match .NET functionality.

Remove code as requested

When trying to decrypt client-side encryption, I get an error in .NET:

The padding is invalid and cannot be deleted.

additional information

If I just press hex as the key (delete .toString(CryptoJS.enc.Latin1)), I get insufficient characters (seems to change to 128 instead of 256).

The actual data returned by MD5_Key in JS seems to match Validate_MD5 in .NET ...

Am I trying to achieve the impossible?

Artjom B.

CryptoJS only supports AES, which is basically Rijndael, but limited to a block size of 128 bits. It supports key sizes of 128, 192 and 256 bits. Your .net code uses Rijndael, which has a block size of 256, which is not supported by CryptoJS. CryptoJS happily takes a large IV and only uses the first 16 bytes.

You will have to find another library that supports this as you cannot change the .net code.

Related


Create a CryptoJS AES password encryptor to decrypt in .NET

Jamie Barker I'm trying to create encryption/decryption that will work between server/client. I use CryptoJS on the client side and ASP.Net (VB.Net) on the server side. The server side is used in many places so it can't be changed, so CryptoJS needs to work ar

Create a CryptoJS AES password encryptor to decrypt in .NET

Jamie Barker I'm trying to create encryption/decryption that will work between server/client. I use CryptoJS on the client side and ASP.Net (VB.Net) on the server side. The server side is used in many places so it can't be changed, so CryptoJS needs to work ar

Create a CryptoJS AES password encryptor to decrypt in .NET

Jamie Barker I'm trying to create encryption/decryption that will work between server/client. I use CryptoJS on the client side and ASP.Net (VB.Net) on the server side. The server side is used in many places so it can't be changed, so CryptoJS needs to work ar

Create a CryptoJS AES password encryptor to decrypt in .NET

Jamie Barker I'm trying to create encryption/decryption that will work between server/client. I use CryptoJS on the client side and ASP.Net (VB.Net) on the server side. The server side is used in many places so it can't be changed, so CryptoJS needs to work ar

Decrypt openssl AES with CryptoJS

supply I am trying to decrypt a file encrypted with openssl using CryptoJS 3.1.5 . If I use CryptoJS for encryption and decryption, everything works fine, as does OpenSSL in the shell, but when I try to mix CryptoJS with OpenSSL everything goes wrong. Create t

Decrypt openssl AES with CryptoJS

supply I am trying to decrypt a file encrypted with openssl using CryptoJS 3.1.5 . If I use CryptoJS for encryption and decryption, everything works fine, as does OpenSSL in the shell, but when I try to mix CryptoJS with OpenSSL everything goes wrong. Create t

Encrypt with AES with phpseclib and decrypt with CryptoJS

Roberto 14 I'm trying to encrypt a string using phpseclib AES in CBC mode (the library's default): $cipher = new Crypt_AES(); $cipher->setKey('abcdefghijklmnop'); $cipher->setIV(crypt_random_string($cipher->getBlockLength() >> 3)); $cipher->encrypt("hello worl

How to decrypt with CryptoJS using AES?

User 3197788 With the desired options (AES, ECB mode and PKCS7), as the question suggests, I can't seem to get the decrypted value right. I am encrypting like this: var ENC_KEY = "bXlrZXk="; //"mykey" var encrypted = CryptoJS.AES.encrypt("hello", Crypto

Encrypt with AES with phpseclib and decrypt with CryptoJS

Roberto 14 I'm trying to encrypt a string using phpseclib AES in CBC mode (the library's default): $cipher = new Crypt_AES(); $cipher->setKey('abcdefghijklmnop'); $cipher->setIV(crypt_random_string($cipher->getBlockLength() >> 3)); $cipher->encrypt("hello worl

How to decrypt with CryptoJS using AES?

User 3197788 With the desired options (AES, ECB mode and PKCS7), as the question suggests, I can't seem to get the decrypted value right. I am encrypting like this: var ENC_KEY = "bXlrZXk="; //"mykey" var encrypted = CryptoJS.AES.encrypt("hello", Crypto

Encrypt (cryptojs) - Decrypt (.NET)

and The password will be encrypted in .NET using AES and stored in the database. In another application, using javascript (on top of Rhino engine) and cryptojs library, I need to decrypt the password and then use it. The solution doesn't have to be complicated

Encrypt (cryptojs) - Decrypt (.NET)

dirty The password will be encrypted in .NET using AES and stored in the database. In another application, using javascript (on top of the Rhino engine) and the cryptojs library, I need to decrypt the password before using it. The solution doesn't have to be c

Encrypt (cryptojs) - Decrypt (.NET)

dirty The password will be encrypted in .NET using AES and stored in the database. In another application, using javascript (on top of the Rhino engine) and the cryptojs library, I need to decrypt the password before using it. The solution doesn't have to be c

Unable to decrypt password using CryptoJS

Jojo 01 I am trying to encrypt using CryptoJS. The encryption seems to work fine, but when I decrypt the password, I don't get the initial plain text password. Here is my javascript code: <script type="text/javascript"> var password = ""; function noSsl() {

Unable to decrypt password using CryptoJS

Jojo 01 I am trying to encrypt using CryptoJS. The encryption seems to work fine, but when I decrypt the password, I don't get the initial plain text password. Here is my javascript code: <script type="text/javascript"> var password = ""; function noSsl() {

Unable to decrypt password using CryptoJS

Jojo 01 I am trying to encrypt using CryptoJS. The encryption seems to work fine, but when I decrypt the password, I don't get the initial plain text password. Here is my javascript code: <script type="text/javascript"> var password = ""; function noSsl() {

Decrypt AES input on Flutter, use cryptoJS AES on the web

Nguyen Van On the web, I use CryptoJS to decrypt JS: CryptoJS.AES.decrypt(inputBase64, key).toString(CryptoJS.enc.Utf8); example: Input: "tzfwnxVwE/qNoaWRRfqLp11ZyhB4UtKO+0/Lvv5B7eE=" Key: "20190225165436_15230006321670000_15510884759030000" I can't find any l

Decrypt AES input on Flutter, use cryptoJS AES on the web

Nguyen Van On the web, I use CryptoJS to decrypt JS: CryptoJS.AES.decrypt(inputBase64, key).toString(CryptoJS.enc.Utf8); example: Input: "tzfwnxVwE/qNoaWRRfqLp11ZyhB4UtKO+0/Lvv5B7eE=" Key: "20190225165436_15230006321670000_15510884759030000" I can't find any l

How to decrypt cryptojs AES encrypted message on Java server side?

user1455719: I have the following cryptojs based javascript encrypt/decrypt functions and they work fine. When encrypting a message with cryptpjs, I use a random salt, a random iv value and a specific cipher. When decrypting the encrypted message, I reused the

CryptoJS decrypt (AES) file byte array from Java

Sandeep I am encrypting a file in Java and need to decrypt it on the client side. Here is the server side code: Key secretKey = new SecretKeySpec("mysecretmysecret".getBytes(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE,

How to decrypt cryptojs AES encrypted message on Java server side?

user1455719: I have the following cryptojs based javascript encrypt/decrypt functions and they work fine. When encrypting a message with cryptpjs, I use a random salt, a random iv value and a specific cipher. When decrypting the encrypted message, I reused the

CryptoJS AES decrypt message encrypted with PHP openssl_encrypt

Braque I have the following PHP code openssl_encrypt()that encrypts a message using a function . Here is the code: $ciphering = "AES-128-CTR"; $options = 0; $encryption_iv = '5192001995060634'; $encryption_key = "TasKagitMakas"; function encrypt ($string) {