Subversion Repositories cryptochat

Rev

View as "text/javascript" | Blame | Last modification | View Log | RSS feed

  1. /*
  2. CryptoJS v3.1.2
  3. code.google.com/p/crypto-js
  4. (c) 2009-2013 by Jeff Mott. All rights reserved.
  5. code.google.com/p/crypto-js/wiki/License
  6. */
  7. (function (undefined) {
  8.     // Shortcuts
  9.     var C = CryptoJS;
  10.     var C_lib = C.lib;
  11.     var CipherParams = C_lib.CipherParams;
  12.     var C_enc = C.enc;
  13.     var Hex = C_enc.Hex;
  14.     var C_format = C.format;
  15.  
  16.     var HexFormatter = C_format.Hex = {
  17.         /**
  18.          * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  19.          *
  20.          * @param {CipherParams} cipherParams The cipher params object.
  21.          *
  22.          * @return {string} The hexadecimally encoded string.
  23.          *
  24.          * @static
  25.          *
  26.          * @example
  27.          *
  28.          *     var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  29.          */
  30.         stringify: function (cipherParams) {
  31.             return cipherParams.ciphertext.toString(Hex);
  32.         },
  33.  
  34.         /**
  35.          * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  36.          *
  37.          * @param {string} input The hexadecimally encoded string.
  38.          *
  39.          * @return {CipherParams} The cipher params object.
  40.          *
  41.          * @static
  42.          *
  43.          * @example
  44.          *
  45.          *     var cipherParams = CryptoJS.format.Hex.parse(hexString);
  46.          */
  47.         parse: function (input) {
  48.             var ciphertext = Hex.parse(input);
  49.             return CipherParams.create({ ciphertext: ciphertext });
  50.         }
  51.     };
  52. }());
  53.