AI销管
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

54 行
1.3 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. /**
  16. * Output Feedback block mode.
  17. */
  18. CryptoJS.mode.OFB = (function () {
  19. var OFB = CryptoJS.lib.BlockCipherMode.extend();
  20. var Encryptor = OFB.Encryptor = OFB.extend({
  21. processBlock: function (words, offset) {
  22. // Shortcuts
  23. var cipher = this._cipher
  24. var blockSize = cipher.blockSize;
  25. var iv = this._iv;
  26. var keystream = this._keystream;
  27. // Generate keystream
  28. if (iv) {
  29. keystream = this._keystream = iv.slice(0);
  30. // Remove IV for subsequent blocks
  31. this._iv = undefined;
  32. }
  33. cipher.encryptBlock(keystream, 0);
  34. // Encrypt
  35. for (var i = 0; i < blockSize; i++) {
  36. words[offset + i] ^= keystream[i];
  37. }
  38. }
  39. });
  40. OFB.Decryptor = Encryptor;
  41. return OFB;
  42. }());
  43. return CryptoJS.mode.OFB;
  44. }));