Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting SlowAES and RijndaelManaged class in .NET to play together
    primarykey
    data
    text
    <p>I'm trying to setup AES encryption / decryption using the javascript library <a href="http://code.google.com/p/slowaes/" rel="nofollow noreferrer">SlowAES</a> and the <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx" rel="nofollow noreferrer">RijndaelManaged</a> class in .NET.</p> <p>I chose this method after reading <a href="https://stackoverflow.com/questions/270510/how-to-encrypt-in-vbscript-using-aes/">this post</a>, where Cheeso has managed to get these two encryption methods to play together </p> <blockquote> <p>"In my tests of the COM-wrapped-SlowAEs, I used CBC mode, and the encryption was completely compatible with the RijndaelManaged class in .NET" - Cheeso</p> </blockquote> <p>I've taken the javascript code from Cheeso's Windows Scripting Component, the latest slowaes libraries, and using the following javascript script to test:</p> <pre><code>var key = "12345678901234567890123456789012"; var message = "watson?"; var decrypted; slowAES.aes.keySize.SIZE_256; slowAES.modeOfOperation.CBC; put_PassPhrase(key); var result = EncryptString(message); decrypted = DecryptCommaDelimitedStringToString(result) document.write("Key:" + key + "&lt;br /&gt;original:" + message + "&lt;br /&gt;Cypher:" + result + "&lt;br /&gt;Decrypted:" + decrypted + "&lt;br /&gt;IV(): " + get_IV()); </code></pre> <p>I'm getting the following output:</p> <pre><code>Key:12345678901234567890123456789012 original:watson? Cypher:245,159,1,1,168,1,1,143,1,1,146,1,1,239,117,1 Decrypted:watson? IV(): 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 </code></pre> <p>I've modified the following example found <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx" rel="nofollow noreferrer">on MSDN</a> to try and match the encryption in C# :</p> <pre><code>public static void Main() { try { string original = "watson?"; byte[] IV = new byte[16]; // match slowaes IV byte[] key = new System.Text.ASCIIEncoding().GetBytes("12345678901234567890123456789012");// match slowaes KEY RijndaelManaged myRijndael = new RijndaelManaged(); myRijndael.BlockSize = 128; myRijndael.KeySize = 256; myRijndael.Mode = CipherMode.CBC; // Encrypt the string to an array of bytes. byte[] encrypted = encryptStringToBytes_AES(original, key, IV); // Decrypt the bytes to a string. string roundtrip = decryptStringFromBytes_AES(encrypted, key, IV); //Display the original data and the decrypted data. Console.WriteLine("Original: {0}", original); Console.WriteLine("Round Trip: {0}", roundtrip); } catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); } } </code></pre> <p>Watch of the byte array:</p> <pre><code>- encrypted {byte[16]} byte[] [0] 139 byte [1] 104 byte [2] 166 byte [3] 35 byte [4] 8 byte [5] 42 byte [6] 216 byte [7] 160 byte [8] 235 byte [9] 153 byte [10] 23 byte [11] 143 byte [12] 105 byte [13] 3 byte [14] 24 byte [15] 255 byte </code></pre> <p>I've tried all the padding options with the managed .NET class, however I can't get the encrypted outputs to match. Can anyone help me?</p> <p>Thanks,</p> <p>Bob</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload