AI销管
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

66 line
1.8 KiB

  1. ;(function (root, factory, undef) {
  2. if (typeof exports === "object") {
  3. // CommonJS
  4. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  5. }
  6. else if (typeof define === "function" && define.amd) {
  7. // AMD
  8. define(["./core", "./cipher-core"], factory);
  9. }
  10. else {
  11. // Global (browser)
  12. factory(root.CryptoJS);
  13. }
  14. }(this, function (CryptoJS) {
  15. (function (undefined) {
  16. // Shortcuts
  17. var C = CryptoJS;
  18. var C_lib = C.lib;
  19. var CipherParams = C_lib.CipherParams;
  20. var C_enc = C.enc;
  21. var Hex = C_enc.Hex;
  22. var C_format = C.format;
  23. var HexFormatter = C_format.Hex = {
  24. /**
  25. * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  26. *
  27. * @param {CipherParams} cipherParams The cipher params object.
  28. *
  29. * @return {string} The hexadecimally encoded string.
  30. *
  31. * @static
  32. *
  33. * @example
  34. *
  35. * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  36. */
  37. stringify: function (cipherParams) {
  38. return cipherParams.ciphertext.toString(Hex);
  39. },
  40. /**
  41. * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  42. *
  43. * @param {string} input The hexadecimally encoded string.
  44. *
  45. * @return {CipherParams} The cipher params object.
  46. *
  47. * @static
  48. *
  49. * @example
  50. *
  51. * var cipherParams = CryptoJS.format.Hex.parse(hexString);
  52. */
  53. parse: function (input) {
  54. var ciphertext = Hex.parse(input);
  55. return CipherParams.create({ ciphertext: ciphertext });
  56. }
  57. };
  58. }());
  59. return CryptoJS.format.Hex;
  60. }));