ESTK output

CryptoJS Tutorial For Dummies

Davide Barranca — 
Print Friendly

14 responses to CryptoJS Tutorial For Dummies

  1. “Components files have dependencies: you have to link at least core.js, while rollups are quite self contained.” – that’s just the info I was looking for, thank you. 🙂

  2. Hi, could you help me a bit more please? Do you know how can I generate the key from a passphrase using crypto-js? I have an encrypted byte array from my webservice (c#), and I have the IV which I also send to the client. There is no clear documentation about how to generate the key itself. I guess I would be able to decrypt it using this: var decrypted = CryptoJS.AES.decrypt(encrypted, key, { iv: iv });

    I also posted my problem here:


  3. If I am encrypting say the contents of an html file, saving that file overwriting with the contents of the encryption, what encrypted value do I save the file as? encrypted.toString() ?

    encrypting as:

    encryption=CryptoJS.AES.encrypt(originalText,”my key phrase”);

    MyHTMLFile contents reset to encryption.toString()

    I have tried that and other options, but I can’t get my decrypting to return the correct text. In decryption, I am trying a

    encryptedText = myHTMLFile.readfile().toString();

    CryptoJS.AES.decrypt(encryptedText,”my key phrase);

    and it is not returning the original text.

    How do I read the encrypted file as string value and transform that into something I can use in decrypt method?

  4. Did anybody notice that the encrypted text has ALWAYS the same characters at the beginning, no matter what text you encrypt? Could anybody explain this behaviour? Isn’t this purely poor encrypted and unsecure by default?
    Thanks in advance.

  5. I’ve started a thread on stackoverflow about outputing the cypher to a string. This relates to your blog post under Input/Output where you mention in an update about .toString()

    Others have commented earlier to mine that they are having trouble and I also have found that it doesn’t work or there is a missing piece that we don’t know. Its not as simple as putting .toString on the end.

    Here is the link to the stackoverflow thread and included there are jsFiddles examples. If you have got it working please let us know

  6. In addition CryptoJs there are other interesting libraries.
    Look here:

  7. Hi Davide Barranca,
    I would like to use php mcrypt_encrypt methode in javascript using crypto js. can pls help me for this?

  8. Hello,

    I would like to use the AES function in order to encrypt a ” file ” such as pdf, word… but It seems that CryptoJS.AES.encrypt(“Message”, “Secret Passphrase”) can take only a string or word array as a parameter,

    Please could anyone help me about this question or is there any other lib in javascript wich handles functions wich accepte files.

    Thank you

  9. Ricardo Andrade May 2, 2014 at 10:25 PM

    Thanks a lot! It was very helpful!

    So, Did you know if is possible do not use a Passphrase directly in the code? Use a public key, for example?

Trackbacks and Pingbacks:

  1. Заготовки для аутентификации. | Computerman - February 23, 2015

    […] Тестирование показало корректную работу реализаций на JavaScript в связке с реализациями на Java. Полезные ссылки. 1. Официальная документация class MessageDigest, class Cipher. 2. Crypto JS. 2. Crypto JS tutorial for dummies. […]