AI销管
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pad-ansix923.js 1.2 KiB

2 년 전
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. /**
  16. * ANSI X.923 padding strategy.
  17. */
  18. CryptoJS.pad.AnsiX923 = {
  19. pad: function (data, blockSize) {
  20. // Shortcuts
  21. var dataSigBytes = data.sigBytes;
  22. var blockSizeBytes = blockSize * 4;
  23. // Count padding bytes
  24. var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
  25. // Compute last byte position
  26. var lastBytePos = dataSigBytes + nPaddingBytes - 1;
  27. // Pad
  28. data.clamp();
  29. data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
  30. data.sigBytes += nPaddingBytes;
  31. },
  32. unpad: function (data) {
  33. // Get number of padding bytes from last byte
  34. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  35. // Remove padding
  36. data.sigBytes -= nPaddingBytes;
  37. }
  38. };
  39. return CryptoJS.pad.Ansix923;
  40. }));