{"id":30983,"date":"2017-04-10T10:09:44","date_gmt":"2017-04-10T14:09:44","guid":{"rendered":"http:\/\/www.opensource.im\/?p=30983"},"modified":"2017-04-10T10:09:44","modified_gmt":"2017-04-10T14:09:44","slug":"javascript-aes-encryption-stack-overflow","status":"publish","type":"post","link":"https:\/\/euvolution.com\/open-source-convergence\/encryption\/javascript-aes-encryption-stack-overflow.php","title":{"rendered":"Javascript AES encryption &#8211; Stack Overflow"},"content":{"rendered":"<p><p>    Here's a    demonstration page that uses slowAES.  <\/p>\n<p>    slowAES was easy    to use. Logically designed. Reasonable OO packaging. Supports    knobs and levers like IV and Encryption mode. Good    compatibility with .NET\/C#. The name is tongue-in-cheek; it's    called \"slow AES\" because it's not implemented    in C++. But in my tests it was not impractically slow.  <\/p>\n<p>    It lacks an ECB mode. Also lacks a CTR mode, although you could    build one pretty easily given an ECB mode, I guess.  <\/p>\n<p>    It is solely focused on encryption. A nice complementary class    that does RFC2898-compliant    password-based key derivation, in Javascript, is available from Anandam. This    pair of libraries works well with the analogous .NET classes.    Good interop. Though, in contrast to SlowAES, the Javascript    PBKDF2 is noticeably slower than the     Rfc2898DeriveBytes class when generating keys.  <\/p>\n<p>    It's not surprising that technically there is good interop, but    the key point for me was the model adopted by SlowAES is    familiar and easy to use. I found some of the other Javascript    libraries for AES to be hard to understand and use. For    example, in some of them I couldn't find the place to set the    IV, or the mode (CBC, ECB, etc). Things were not where I    expected them to be. SlowAES was not like that. The properties    were right where I expected them to be. It was easy for me to    pick up, having been familiar with the Java and .NET crypto    programming models.  <\/p>\n<p>    Anandam's PBKDF2 was not quite on that level. It supported only    a single call to DeriveBytes function, so if you need to derive    both a key and an IV from a password, this library won't work,    unchanged. Some slight modification, and it is working just    fine for that purpose.  <\/p>\n<p>    EDIT: I put together     an example of packaging SlowAES and a modified    version of Anandam's PBKDF2 into Windows Script    Components. Using this AES with a password-derived key shows    good interop with the .NET RijndaelManaged class.  <\/p>\n<p>    EDIT2: the demo    page shows how to use this AES encryption from a web page.    Using the same inputs (iv, key, mode, etc) supported in .NET    gives you good interop with the .NET Rijndael class. You can do    a \"view source\" to get the javascript for that page.  <\/p>\n<p>    EDIT3    a late addition: Javascript    Cryptography considered harmful. Worth the read.  <\/p>\n<p><!-- Auto Generated --><\/p>\n<p>Read more here:<br \/>\n<a target=\"_blank\" href=\"http:\/\/stackoverflow.com\/questions\/793812\/javascript-aes-encryption\" title=\"Javascript AES encryption - Stack Overflow\">Javascript AES encryption - Stack Overflow<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> Here's a demonstration page that uses slowAES. slowAES was easy to use. Logically designed. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[],"class_list":["post-30983","post","type-post","status-publish","format-standard","hentry","category-encryption"],"_links":{"self":[{"href":"https:\/\/euvolution.com\/open-source-convergence\/wp-json\/wp\/v2\/posts\/30983"}],"collection":[{"href":"https:\/\/euvolution.com\/open-source-convergence\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/euvolution.com\/open-source-convergence\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/euvolution.com\/open-source-convergence\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/euvolution.com\/open-source-convergence\/wp-json\/wp\/v2\/comments?post=30983"}],"version-history":[{"count":0,"href":"https:\/\/euvolution.com\/open-source-convergence\/wp-json\/wp\/v2\/posts\/30983\/revisions"}],"wp:attachment":[{"href":"https:\/\/euvolution.com\/open-source-convergence\/wp-json\/wp\/v2\/media?parent=30983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/euvolution.com\/open-source-convergence\/wp-json\/wp\/v2\/categories?post=30983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/euvolution.com\/open-source-convergence\/wp-json\/wp\/v2\/tags?post=30983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}