提交subgame插件
This commit is contained in:
20
node_modules/xxtea-node/LICENSE.md
generated
vendored
Normal file
20
node_modules/xxtea-node/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2008-2016 Ma Bingyao <mabingyao@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
48
node_modules/xxtea-node/README.md
generated
vendored
Normal file
48
node_modules/xxtea-node/README.md
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# XXTEA for Node.js
|
||||
|
||||
<a href="https://github.com/xxtea/">
|
||||
<img src="https://avatars1.githubusercontent.com/u/6683159?v=3&s=86" alt="XXTEA logo" title="XXTEA" align="right" />
|
||||
</a>
|
||||
|
||||
[](https://gitter.im/xxtea/xxtea-nodejs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://www.npmjs.com/package/xxtea-node)
|
||||
[](https://www.npmjs.com/package/xxtea-node)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
|
||||
## Introduction
|
||||
|
||||
XXTEA is a fast and secure encryption algorithm. This is a XXTEA library for Node.js.
|
||||
|
||||
It is different from the original XXTEA encryption algorithm. It encrypts and decrypts Uint8Array instead of uint32[], and the key is also Uint8Array. If you want to encrypt String, you can use xxtea.toBytes(str) to convert String to Uint8Array, when you decrypt Uint8Array, you can use xxtea.toString(bytes) to convert the result to String. Conversion between string and Uint8Array is using UTF8 encoding.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var xxtea = require('xxtea-node');
|
||||
|
||||
var str = "Hello World! 你好,中国!";
|
||||
var key = "1234567890";
|
||||
var encrypt_data = xxtea.encrypt(xxtea.toBytes(str), xxtea.toBytes(key));
|
||||
console.log(new Buffer(encrypt_data).toString('base64'));
|
||||
var decrypt_data = xxtea.toString(xxtea.decrypt(encrypt_data, xxtea.toBytes(key)));
|
||||
console.assert(str === decrypt_data);
|
||||
```
|
||||
|
||||
## ChangeLog
|
||||
|
||||
1.1.0 update
|
||||
|
||||
* Fixed Emoji encode & decode bug.
|
||||
* Improved Long String encrypt and decrypt.
|
||||
* Added `encryptToString` and `decryptToString`, for example:
|
||||
|
||||
```javascript
|
||||
var xxtea = require('xxtea-node');
|
||||
|
||||
var str = "Hello World! 你好,中国🇨🇳!";
|
||||
var key = "1234567890";
|
||||
var encrypt_data = xxtea.encryptToString(str, key);
|
||||
console.log(encrypt_data);
|
||||
var decrypt_data = xxtea.decryptToString(encrypt_data, key);
|
||||
console.assert(str === decrypt_data);
|
||||
```
|
||||
48
node_modules/xxtea-node/README_zh_CN.md
generated
vendored
Normal file
48
node_modules/xxtea-node/README_zh_CN.md
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# XXTEA 加密算法的 Node.js 实现
|
||||
|
||||
<a href="https://github.com/xxtea/">
|
||||
<img src="https://avatars1.githubusercontent.com/u/6683159?v=3&s=86" alt="XXTEA logo" title="XXTEA" align="right" />
|
||||
</a>
|
||||
|
||||
[](https://gitter.im/xxtea/xxtea-nodejs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://www.npmjs.com/package/xxtea-node)
|
||||
[](https://www.npmjs.com/package/xxtea-node)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
|
||||
## 简介
|
||||
|
||||
XXTEA 是一个快速安全的加密算法。本项目是 XXTEA 加密算法的 Node.js 实现。
|
||||
|
||||
它不同于原始的 XXTEA 加密算法。它是针对 Uint8Array 类型数据进行加密的,而不是针对 uint32 数组。同样,密钥也是 Uint8Array 类型。如果你想加密字符串,你可以使用 xxtea.toBytes(str) 来将字符串转换为 Uint8Array。当你解密 Uint8Array 时,你可以使用 xxtea.toString(bytes) 来将结果转换为字符串。字符串与 Uint8Array 之间的转换,是采用 UTF8 编码的。
|
||||
|
||||
## 使用
|
||||
|
||||
```javascript
|
||||
var xxtea = require('xxtea-node');
|
||||
|
||||
var str = "Hello World! 你好,中国!";
|
||||
var key = "1234567890";
|
||||
var encrypt_data = xxtea.encrypt(xxtea.toBytes(str), xxtea.toBytes(key));
|
||||
console.log(new Buffer(encrypt_data).toString('base64'));
|
||||
var decrypt_data = xxtea.toString(xxtea.decrypt(encrypt_data, xxtea.toBytes(key)));
|
||||
console.assert(str === decrypt_data);
|
||||
```
|
||||
|
||||
## 更新日志
|
||||
|
||||
1.1.0 更新
|
||||
|
||||
* 修正了表情符编码解码的问题。
|
||||
* 改进了长字符串的加密解密。
|
||||
* 增加了 `encryptToString` 和 `decryptToString` 方法,例如:
|
||||
|
||||
```javascript
|
||||
var xxtea = require('xxtea-node');
|
||||
|
||||
var str = "Hello World! 你好,中国🇨🇳!";
|
||||
var key = "1234567890";
|
||||
var encrypt_data = xxtea.encryptToString(str, key);
|
||||
console.log(encrypt_data);
|
||||
var decrypt_data = xxtea.decryptToString(encrypt_data, key);
|
||||
console.assert(str === decrypt_data);
|
||||
```
|
||||
11
node_modules/xxtea-node/example/xxtea_test.js
generated
vendored
Normal file
11
node_modules/xxtea-node/example/xxtea_test.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/*jshint node:true, eqeqeq:true */
|
||||
'use strict';
|
||||
|
||||
var xxtea = require('xxtea-node');
|
||||
|
||||
var str = "Hello World! 你好,中国🇨🇳!";
|
||||
var key = "1234567890";
|
||||
var encrypt_data = xxtea.encryptToString(str, key);
|
||||
console.log(encrypt_data);
|
||||
var decrypt_data = xxtea.decryptToString(encrypt_data, key);
|
||||
console.assert(str === decrypt_data);
|
||||
324
node_modules/xxtea-node/lib/xxtea.js
generated
vendored
Normal file
324
node_modules/xxtea-node/lib/xxtea.js
generated
vendored
Normal file
@@ -0,0 +1,324 @@
|
||||
/**********************************************************\
|
||||
| |
|
||||
| xxtea.js |
|
||||
| |
|
||||
| XXTEA encryption algorithm library for Node.js. |
|
||||
| |
|
||||
| Encryption Algorithm Authors: |
|
||||
| David J. Wheeler |
|
||||
| Roger M. Needham |
|
||||
| |
|
||||
| Code Author: Ma Bingyao <mabingyao@gmail.com> |
|
||||
| LastModified: Dec 27, 2019 |
|
||||
| |
|
||||
\**********************************************************/
|
||||
|
||||
/*jshint node:true, eqeqeq:true */
|
||||
'use strict';
|
||||
|
||||
var delta = 0x9E3779B9;
|
||||
|
||||
function toUint8Array(v, includeLength) {
|
||||
var length = v.length;
|
||||
var n = length << 2;
|
||||
if (includeLength) {
|
||||
var m = v[length - 1];
|
||||
n -= 4;
|
||||
if ((m < n - 3) || (m > n)) {
|
||||
return null;
|
||||
}
|
||||
n = m;
|
||||
}
|
||||
var bytes = new Uint8Array(n);
|
||||
for (var i = 0; i < n; ++i) {
|
||||
bytes[i] = v[i >> 2] >> ((i & 3) << 3);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
function toUint32Array(bytes, includeLength) {
|
||||
var length = bytes.length;
|
||||
var n = length >> 2;
|
||||
if ((length & 3) !== 0) {
|
||||
++n;
|
||||
}
|
||||
var v;
|
||||
if (includeLength) {
|
||||
v = new Uint32Array(n + 1);
|
||||
v[n] = length;
|
||||
}
|
||||
else {
|
||||
v = new Uint32Array(n);
|
||||
}
|
||||
for (var i = 0; i < length; ++i) {
|
||||
v[i >> 2] |= bytes[i] << ((i & 3) << 3);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
function mx(sum, y, z, p, e, k) {
|
||||
return ((z >>> 5 ^ y << 2) + (y >>> 3 ^ z << 4)) ^ ((sum ^ y) + (k[p & 3 ^ e] ^ z));
|
||||
}
|
||||
|
||||
function fixk(k) {
|
||||
if (k.length < 16) {
|
||||
var key = new Uint8Array(16);
|
||||
key.set(k);
|
||||
k = key;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
function encryptUint32Array(v, k) {
|
||||
var length = v.length;
|
||||
var n = length - 1;
|
||||
var y, z, sum, e, p, q;
|
||||
z = v[n];
|
||||
sum = 0;
|
||||
for (q = Math.floor(6 + 52 / length) | 0; q > 0; --q) {
|
||||
sum += delta;
|
||||
e = sum >>> 2 & 3;
|
||||
for (p = 0; p < n; ++p) {
|
||||
y = v[p + 1];
|
||||
z = v[p] += mx(sum, y, z, p, e, k);
|
||||
}
|
||||
y = v[0];
|
||||
z = v[n] += mx(sum, y, z, p, e, k);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
function decryptUint32Array(v, k) {
|
||||
var length = v.length;
|
||||
var n = length - 1;
|
||||
var y, z, sum, e, p, q;
|
||||
y = v[0];
|
||||
q = Math.floor(6 + 52 / length);
|
||||
for (sum = q * delta; sum !== 0; sum -= delta) {
|
||||
e = sum >>> 2 & 3;
|
||||
for (p = n; p > 0; --p) {
|
||||
z = v[p - 1];
|
||||
y = v[p] -= mx(sum, y, z, p, e, k);
|
||||
}
|
||||
z = v[n];
|
||||
y = v[0] -= mx(sum, y, z, p, e, k);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
function toBytes(str) {
|
||||
var n = str.length;
|
||||
// A single code unit uses at most 3 bytes.
|
||||
// Two code units at most 4.
|
||||
var bytes = new Uint8Array(n * 3);
|
||||
var length = 0;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var codeUnit = str.charCodeAt(i);
|
||||
if (codeUnit < 0x80) {
|
||||
bytes[length++] = codeUnit;
|
||||
}
|
||||
else if (codeUnit < 0x800) {
|
||||
bytes[length++] = 0xC0 | (codeUnit >> 6);
|
||||
bytes[length++] = 0x80 | (codeUnit & 0x3F);
|
||||
}
|
||||
else if (codeUnit < 0xD800 || codeUnit > 0xDFFF) {
|
||||
bytes[length++] = 0xE0 | (codeUnit >> 12);
|
||||
bytes[length++] = 0x80 | ((codeUnit >> 6) & 0x3F);
|
||||
bytes[length++] = 0x80 | (codeUnit & 0x3F);
|
||||
}
|
||||
else {
|
||||
if (i + 1 < n) {
|
||||
var nextCodeUnit = str.charCodeAt(i + 1);
|
||||
if (codeUnit < 0xDC00 && 0xDC00 <= nextCodeUnit && nextCodeUnit <= 0xDFFF) {
|
||||
var rune = (((codeUnit & 0x03FF) << 10) | (nextCodeUnit & 0x03FF)) + 0x010000;
|
||||
bytes[length++] = 0xF0 | (rune >> 18);
|
||||
bytes[length++] = 0x80 | ((rune >> 12) & 0x3F);
|
||||
bytes[length++] = 0x80 | ((rune >> 6) & 0x3F);
|
||||
bytes[length++] = 0x80 | (rune & 0x3F);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
throw new Error('Malformed string');
|
||||
}
|
||||
}
|
||||
return bytes.subarray(0, length);
|
||||
}
|
||||
|
||||
function toShortString(bytes, n) {
|
||||
var charCodes = new Uint16Array(n);
|
||||
var i = 0, off = 0;
|
||||
for (var len = bytes.length; i < n && off < len; i++) {
|
||||
var unit = bytes[off++];
|
||||
switch (unit >> 4) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
charCodes[i] = unit;
|
||||
break;
|
||||
case 12:
|
||||
case 13:
|
||||
if (off < len) {
|
||||
charCodes[i] = ((unit & 0x1F) << 6) |
|
||||
(bytes[off++] & 0x3F);
|
||||
}
|
||||
else {
|
||||
throw new Error('Unfinished UTF-8 octet sequence');
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (off + 1 < len) {
|
||||
charCodes[i] = ((unit & 0x0F) << 12) |
|
||||
((bytes[off++] & 0x3F) << 6) |
|
||||
(bytes[off++] & 0x3F);
|
||||
}
|
||||
else {
|
||||
throw new Error('Unfinished UTF-8 octet sequence');
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
if (off + 2 < len) {
|
||||
var rune = (((unit & 0x07) << 18) |
|
||||
((bytes[off++] & 0x3F) << 12) |
|
||||
((bytes[off++] & 0x3F) << 6) |
|
||||
(bytes[off++] & 0x3F)) - 0x10000;
|
||||
if (0 <= rune && rune <= 0xFFFFF) {
|
||||
charCodes[i++] = (((rune >> 10) & 0x03FF) | 0xD800);
|
||||
charCodes[i] = ((rune & 0x03FF) | 0xDC00);
|
||||
}
|
||||
else {
|
||||
throw new Error('Character outside valid Unicode range: 0x' + rune.toString(16));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error('Unfinished UTF-8 octet sequence');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error('Bad UTF-8 encoding 0x' + unit.toString(16));
|
||||
}
|
||||
}
|
||||
if (i < n) {
|
||||
charCodes = charCodes.subarray(0, i);
|
||||
}
|
||||
return String.fromCharCode.apply(String, charCodes);
|
||||
}
|
||||
|
||||
function toLongString(bytes, n) {
|
||||
var buf = [];
|
||||
var charCodes = new Uint16Array(0x8000);
|
||||
var i = 0, off = 0;
|
||||
for (var len = bytes.length; i < n && off < len; i++) {
|
||||
var unit = bytes[off++];
|
||||
switch (unit >> 4) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
charCodes[i] = unit;
|
||||
break;
|
||||
case 12:
|
||||
case 13:
|
||||
if (off < len) {
|
||||
charCodes[i] = ((unit & 0x1F) << 6) |
|
||||
(bytes[off++] & 0x3F);
|
||||
}
|
||||
else {
|
||||
throw new Error('Unfinished UTF-8 octet sequence');
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (off + 1 < len) {
|
||||
charCodes[i] = ((unit & 0x0F) << 12) |
|
||||
((bytes[off++] & 0x3F) << 6) |
|
||||
(bytes[off++] & 0x3F);
|
||||
}
|
||||
else {
|
||||
throw new Error('Unfinished UTF-8 octet sequence');
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
if (off + 2 < len) {
|
||||
var rune = (((unit & 0x07) << 18) |
|
||||
((bytes[off++] & 0x3F) << 12) |
|
||||
((bytes[off++] & 0x3F) << 6) |
|
||||
(bytes[off++] & 0x3F)) - 0x10000;
|
||||
if (0 <= rune && rune <= 0xFFFFF) {
|
||||
charCodes[i++] = (((rune >> 10) & 0x03FF) | 0xD800);
|
||||
charCodes[i] = ((rune & 0x03FF) | 0xDC00);
|
||||
}
|
||||
else {
|
||||
throw new Error('Character outside valid Unicode range: 0x' + rune.toString(16));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error('Unfinished UTF-8 octet sequence');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error('Bad UTF-8 encoding 0x' + unit.toString(16));
|
||||
}
|
||||
if (i >= 0x7FFF - 1) {
|
||||
var size = i + 1;
|
||||
buf.push(String.fromCharCode.apply(String, charCodes.subarray(0, size)));
|
||||
n -= size;
|
||||
i = -1;
|
||||
}
|
||||
}
|
||||
if (i > 0) {
|
||||
buf.push(String.fromCharCode.apply(String, charCodes.subarray(0, i)));
|
||||
}
|
||||
return buf.join('');
|
||||
}
|
||||
|
||||
function toString(bytes) {
|
||||
var n = bytes.length;
|
||||
if (n === 0) return '';
|
||||
return ((n < 0x7FFF) ?
|
||||
toShortString(bytes, n) :
|
||||
toLongString(bytes, n));
|
||||
}
|
||||
|
||||
function encrypt(data, key) {
|
||||
if (typeof data === 'string') data = toBytes(data);
|
||||
if (typeof key === 'string') key = toBytes(key);
|
||||
if (data === undefined || data === null || data.length === 0) {
|
||||
return data;
|
||||
}
|
||||
return toUint8Array(encryptUint32Array(toUint32Array(data, true), toUint32Array(fixk(key), false)), false);
|
||||
}
|
||||
|
||||
function encryptToString(data, key) {
|
||||
return new Buffer(encrypt(data, key)).toString('base64');
|
||||
}
|
||||
|
||||
function decrypt(data, key) {
|
||||
if (typeof data === 'string') data = new Buffer(data, 'base64');
|
||||
if (typeof key === 'string') key = toBytes(key);
|
||||
if (data === undefined || data === null || data.length === 0) {
|
||||
return data;
|
||||
}
|
||||
return toUint8Array(decryptUint32Array(toUint32Array(data, false), toUint32Array(fixk(key), false)), true);
|
||||
}
|
||||
|
||||
function decryptToString(data, key) {
|
||||
return toString(decrypt(data, key));
|
||||
}
|
||||
|
||||
module.exports = Object.create(null, {
|
||||
toBytes: { value: toBytes },
|
||||
toString: { value: toString },
|
||||
encrypt: { value: encrypt },
|
||||
encryptToString: { value: encryptToString },
|
||||
decrypt: { value: decrypt },
|
||||
decryptToString: { value: decryptToString }
|
||||
});
|
||||
33
node_modules/xxtea-node/package.json
generated
vendored
Normal file
33
node_modules/xxtea-node/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "xxtea-node",
|
||||
"version": "1.1.4",
|
||||
"homepage": "https://github.com/xxtea/xxtea-nodejs",
|
||||
"description": "XXTEA is a fast and secure encryption algorithm. This is a XXTEA library for Node.js.",
|
||||
"keywords": [
|
||||
"xxtea",
|
||||
"encrypt",
|
||||
"decrypt"
|
||||
],
|
||||
"author": {
|
||||
"name": "Ma Bingyao",
|
||||
"email": "mabingyao@gmail.com",
|
||||
"url": "https://github.com/xxtea/"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "lib/"
|
||||
},
|
||||
"main": "lib/xxtea.js",
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/xxtea/xxtea-nodejs.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/xxtea/xxtea-nodejs/issues",
|
||||
"email": "mabingyao@gmail.com"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
Reference in New Issue
Block a user