test.coffee 529 B

12345678910111213
  1. Crypto = (require '../cryptojs').Crypto
  2. key = '12345678'
  3. us = 'Hello, 世界!'
  4. mode = new Crypto.mode.ECB Crypto.pad.pkcs7
  5. console.log "ub = #{ub = Crypto.charenc.UTF8.stringToBytes us}"
  6. console.log "eb = #{eb = Crypto.DES.encrypt ub, key, {asBytes: true, mode: mode}}"
  7. console.log "ehs= #{ehs= Crypto.util.bytesToHex eb}"
  8. console.log "eb2= #{eb2= Crypto.util.hexToBytes ehs}"
  9. console.log "ub2= #{ub2= Crypto.DES.decrypt eb2, key, {asBytes: true, mode: mode}}"
  10. console.log "us2= #{us2= Crypto.charenc.UTF8.bytesToString ub2}"