查看: 4087|回复: 2

[原创发布] 【2016.08.11】仿mv 加密 插件

[复制链接]
梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2016-8-11 19:26:41 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 汪汪 于 2016-8-12 18:28 编辑

仿mv 加密 插件     (额,是对mv学习的产物,仅供学习参考。)
  1. //=============================================================================
  2. // Decrypter_add.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc 仿mv加密
  6. * @author wangwang
  7. *
  8. * @param Decrypter_add
  9. * @desc 仿mv加密
  10. * @default 1.0
  11. *
  12. * @param 密钥
  13. * @desc 输入密钥
  14. * @default 测试
  15. *
  16. * @help
  17. *
  18. *
  19. *
  20. */


  21. (function () {

  22.     Decrypter.SIGNATURE = "5250474d56000000";
  23.     Decrypter.VER = "000301";
  24.     Decrypter.REMAIN = "0000000000";


  25.     Decrypter._encryptionKey2 = "";

  26.     Decrypter.save = function (url) {
  27.         var url = url
  28.         var requestFile = new XMLHttpRequest();
  29.         requestFile.open("GET", url);
  30.         requestFile.responseType = "arraybuffer"
  31.         requestFile.onload = function () {
  32.             if (this.status < Decrypter._xhrOk) {
  33.                 var url2 = Decrypter.extToEncryptExt(url)
  34.                 var data
  35.                 if (requestFile.responseType == "arraybuffer") {
  36.                     var data = Decrypter.encryptArrayBuffer(requestFile.response)
  37.                 }  
  38.                 Decrypter.saveFile(data, url2)
  39.             }
  40.         };
  41.         requestFile.send();
  42.     }

  43.     Decrypter.saveFile = function (data, url) {
  44.         var filePath = this.localFileDirectoryPath(url)
  45.         var fs = require('fs');
  46.         fs.writeFile(filePath, data);
  47.         return data;
  48.     };

  49.     Decrypter.localFileDirectoryPath = function (url) {
  50.         var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/' + url);
  51.         if (path.match(/^\/([A-Z]\:)/)) {
  52.             path = path.slice(1);
  53.         }
  54.         return decodeURIComponent(path);
  55.     };


  56.     Decrypter.makerHeaderForArrayBuffer = function () {
  57.         var header = new Buffer(16);
  58.         var ref = this.SIGNATURE + this.VER + this.REMAIN;
  59.         for (i = 0; i < this._headerlength; i++) {
  60.             header[i] = parseInt("0x" + ref.substr(i * 2, 2), 16);
  61.         }
  62.         return header
  63.     }

  64.     Decrypter.encryptArrayBuffer = function (arrayBuffer) {
  65.         var eD = []
  66.         if (arrayBuffer) {
  67.             this.readEncryptionkey()
  68.             var byteArray = new Uint8Array(arrayBuffer);
  69.             for (i = 0; i < this._headerlength; i++) {
  70.                 var key = parseInt(Decrypter._encryptionKey[i], 16)
  71.                 var code = byteArray[i]
  72.                 byteArray[i] = key ^ code
  73.             }
  74.             eD = [this.makerHeaderForArrayBuffer(), new Buffer(byteArray)]
  75.         }
  76.         eD = Buffer.concat(eD)
  77.         return eD
  78.     }

  79.     Decrypter.readEncryptionkey = function () {
  80.         if (!$dataSystem.encryptionKey) {
  81.             $dataSystem.encryptionKey = Decrypter.makeEncryptionKey2()
  82.         }
  83.         this._encryptionKey = $dataSystem.encryptionKey.split(/(.{2})/).filter(Boolean);
  84.     };

  85.     Decrypter.makeEncryptionKey2 = function () {
  86.         if (!Decrypter._encryptionKey2) {
  87.             var miyao = ""
  88.             for (var i = 0; i < $plugins.length; i++) {
  89.                 var plugin = $plugins[i]
  90.                 if ("Decrypter_add" in plugin.parameters ) {
  91.                     if (plugin.status == true) {
  92.                          var miyao = plugin.parameters["密钥"]
  93.                     }
  94.                 }
  95.             }
  96.             Decrypter._encryptionKey2 =  MD5(miyao)
  97.         }
  98.         return Decrypter._encryptionKey2
  99.     };






  100. })();







  101. /**
  102. *
  103. *  MD5 (Message-Digest Algorithm)
  104. *  [url]http://www.webtoolkit.info/[/url]
  105. *
  106. **/

  107. var MD5 = function (string) {

  108.     function RotateLeft(lValue, iShiftBits) {
  109.         return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
  110.     }

  111.     function AddUnsigned(lX, lY) {
  112.         var lX4, lY4, lX8, lY8, lResult;
  113.         lX8 = (lX & 0x80000000);
  114.         lY8 = (lY & 0x80000000);
  115.         lX4 = (lX & 0x40000000);
  116.         lY4 = (lY & 0x40000000);
  117.         lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
  118.         if (lX4 & lY4) {
  119.             return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
  120.         }
  121.         if (lX4 | lY4) {
  122.             if (lResult & 0x40000000) {
  123.                 return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
  124.             } else {
  125.                 return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
  126.             }
  127.         } else {
  128.             return (lResult ^ lX8 ^ lY8);
  129.         }
  130.     }

  131.     function F(x, y, z) { return (x & y) | ((~x) & z); }
  132.     function G(x, y, z) { return (x & z) | (y & (~z)); }
  133.     function H(x, y, z) { return (x ^ y ^ z); }
  134.     function I(x, y, z) { return (y ^ (x | (~z))); }

  135.     function FF(a, b, c, d, x, s, ac) {
  136.         a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
  137.         return AddUnsigned(RotateLeft(a, s), b);
  138.     };

  139.     function GG(a, b, c, d, x, s, ac) {
  140.         a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
  141.         return AddUnsigned(RotateLeft(a, s), b);
  142.     };

  143.     function HH(a, b, c, d, x, s, ac) {
  144.         a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
  145.         return AddUnsigned(RotateLeft(a, s), b);
  146.     };

  147.     function II(a, b, c, d, x, s, ac) {
  148.         a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
  149.         return AddUnsigned(RotateLeft(a, s), b);
  150.     };

  151.     function ConvertToWordArray(string) {
  152.         var lWordCount;
  153.         var lMessageLength = string.length;
  154.         var lNumberOfWords_temp1 = lMessageLength + 8;
  155.         var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64;
  156.         var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
  157.         var lWordArray = Array(lNumberOfWords - 1);
  158.         var lBytePosition = 0;
  159.         var lByteCount = 0;
  160.         while (lByteCount < lMessageLength) {
  161.             lWordCount = (lByteCount - (lByteCount % 4)) / 4;
  162.             lBytePosition = (lByteCount % 4) * 8;
  163.             lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
  164.             lByteCount++;
  165.         }
  166.         lWordCount = (lByteCount - (lByteCount % 4)) / 4;
  167.         lBytePosition = (lByteCount % 4) * 8;
  168.         lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
  169.         lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
  170.         lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
  171.         return lWordArray;
  172.     };

  173.     function WordToHex(lValue) {
  174.         var WordToHexValue = "", WordToHexValue_temp = "", lByte, lCount;
  175.         for (lCount = 0; lCount <= 3; lCount++) {
  176.             lByte = (lValue >>> (lCount * 8)) & 255;
  177.             WordToHexValue_temp = "0" + lByte.toString(16);
  178.             WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2);
  179.         }
  180.         return WordToHexValue;
  181.     };

  182.     function Utf8Encode(string) {
  183.         string = string.replace(/\r\n/g, "\n");
  184.         var utftext = "";

  185.         for (var n = 0; n < string.length; n++) {

  186.             var c = string.charCodeAt(n);

  187.             if (c < 128) {
  188.                 utftext += String.fromCharCode(c);
  189.             }
  190.             else if ((c > 127) && (c < 2048)) {
  191.                 utftext += String.fromCharCode((c >> 6) | 192);
  192.                 utftext += String.fromCharCode((c & 63) | 128);
  193.             }
  194.             else {
  195.                 utftext += String.fromCharCode((c >> 12) | 224);
  196.                 utftext += String.fromCharCode(((c >> 6) & 63) | 128);
  197.                 utftext += String.fromCharCode((c & 63) | 128);
  198.             }

  199.         }

  200.         return utftext;
  201.     };

  202.     var x = Array();
  203.     var k, AA, BB, CC, DD, a, b, c, d;
  204.     var S11 = 7, S12 = 12, S13 = 17, S14 = 22;
  205.     var S21 = 5, S22 = 9, S23 = 14, S24 = 20;
  206.     var S31 = 4, S32 = 11, S33 = 16, S34 = 23;
  207.     var S41 = 6, S42 = 10, S43 = 15, S44 = 21;

  208.     string = Utf8Encode(string);

  209.     x = ConvertToWordArray(string);

  210.     a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;

  211.     for (k = 0; k < x.length; k += 16) {
  212.         AA = a; BB = b; CC = c; DD = d;
  213.         a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
  214.         d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
  215.         c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
  216.         b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
  217.         a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
  218.         d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
  219.         c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
  220.         b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
  221.         a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
  222.         d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
  223.         c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
  224.         b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
  225.         a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
  226.         d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
  227.         c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
  228.         b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
  229.         a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
  230.         d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
  231.         c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
  232.         b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
  233.         a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
  234.         d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
  235.         c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
  236.         b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
  237.         a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
  238.         d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
  239.         c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
  240.         b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
  241.         a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
  242.         d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
  243.         c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
  244.         b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
  245.         a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
  246.         d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
  247.         c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
  248.         b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
  249.         a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
  250.         d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
  251.         c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
  252.         b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
  253.         a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
  254.         d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
  255.         c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
  256.         b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
  257.         a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
  258.         d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
  259.         c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
  260.         b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
  261.         a = II(a, b, c, d, x[k + 0], S41, 0xF4292244);
  262.         d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
  263.         c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
  264.         b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
  265.         a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
  266.         d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
  267.         c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
  268.         b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
  269.         a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
  270.         d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
  271.         c = II(c, d, a, b, x[k + 6], S43, 0xA3014314);
  272.         b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
  273.         a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
  274.         d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
  275.         c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
  276.         b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
  277.         a = AddUnsigned(a, AA);
  278.         b = AddUnsigned(b, BB);
  279.         c = AddUnsigned(c, CC);
  280.         d = AddUnsigned(d, DD);
  281.     }

  282.     var temp = WordToHex(a) + WordToHex(b) + WordToHex(c) + WordToHex(d);

  283.     return temp.toLowerCase();
  284. }



复制代码
梦石
2
星屑
34507
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

发表于 2016-8-11 22:47:09 | 显示全部楼层
看起来很高深的样子!
支持声音图像加密吗?

点评

额,其实就是把mv自带的加密方法变成变成插件了。  发表于 2016-8-12 00:02
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部