@ocap/mcrypto 1.18.40 → 1.18.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Crypter from '../protocols/crypter';
|
|
2
|
+
declare class AesCrypter extends Crypter {
|
|
3
|
+
encrypt(message: string | object, secret: string): string;
|
|
4
|
+
decrypt(cipher: string, secret: string, outputEncoding?: string): string;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: AesCrypter;
|
|
7
|
+
export default _default;
|
|
8
|
+
export { AesCrypter };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.AesCrypter = void 0;
|
|
30
|
+
const AES = __importStar(require("crypto-js/aes"));
|
|
31
|
+
const enc_latin1_1 = __importDefault(require("crypto-js/enc-latin1"));
|
|
32
|
+
const enc_utf8_1 = __importDefault(require("crypto-js/enc-utf8"));
|
|
33
|
+
const enc_utf16_1 = __importDefault(require("crypto-js/enc-utf16"));
|
|
34
|
+
const enc_base64_1 = __importDefault(require("crypto-js/enc-base64"));
|
|
35
|
+
const enc_hex_1 = __importDefault(require("crypto-js/enc-hex"));
|
|
36
|
+
const crypter_1 = __importDefault(require("../protocols/crypter"));
|
|
37
|
+
const encoders = {
|
|
38
|
+
latin1: enc_latin1_1.default,
|
|
39
|
+
utf8: enc_utf8_1.default,
|
|
40
|
+
hex: enc_hex_1.default,
|
|
41
|
+
utf16: enc_utf16_1.default,
|
|
42
|
+
base64: enc_base64_1.default,
|
|
43
|
+
};
|
|
44
|
+
// AES-CBC-256
|
|
45
|
+
class AesCrypter extends crypter_1.default {
|
|
46
|
+
encrypt(message, secret) {
|
|
47
|
+
const text = typeof message === 'string' ? message : JSON.stringify(message);
|
|
48
|
+
return AES.encrypt(text, secret).toString();
|
|
49
|
+
}
|
|
50
|
+
decrypt(cipher, secret, outputEncoding = 'utf8') {
|
|
51
|
+
return AES.decrypt(cipher, secret).toString(encoders[outputEncoding]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.AesCrypter = AesCrypter;
|
|
55
|
+
exports.default = new AesCrypter();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/mcrypto",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.42",
|
|
4
4
|
"description": "Crypto lib that provides signer,crypter,hasher interface",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crypto",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"url": "https://github.com/ArcBlock/asset-chain/issues"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@ocap/util": "1.18.
|
|
59
|
+
"@ocap/util": "1.18.42",
|
|
60
60
|
"bn.js": "5.2.1",
|
|
61
61
|
"crypto-js": "^4.1.1",
|
|
62
62
|
"elliptic": "^6.5.4",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"bn.js": "5.2.1",
|
|
73
73
|
"elliptic": "6.5.3"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "e4c81bf4891fd7b1b1ce3b8e1ccf7c4b7c004593"
|
|
76
76
|
}
|