aes-bridge 2.0.4 → 2.0.6

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.
package/src/md5.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ type InputType = string | number[] | Uint8Array | ArrayBuffer;
2
+
3
+ interface Md5 {
4
+ update(message: InputType): Md5;
5
+ hex(): string;
6
+ toString(): string;
7
+ digest(): number[];
8
+ array(): number[];
9
+ arrayBuffer(): ArrayBuffer;
10
+ buffer(): ArrayBuffer;
11
+ base64(): string;
12
+ }
13
+
14
+ interface HmacMd5 extends Md5 {}
15
+
16
+ interface Md5Static {
17
+ (message: InputType): string;
18
+ hex(message: InputType): string;
19
+ array(message: InputType): number[];
20
+ digest(message: InputType): number[];
21
+ arrayBuffer(message: InputType): ArrayBuffer;
22
+ buffer(message: InputType): ArrayBuffer;
23
+ base64(message: InputType): string;
24
+ create(): Md5;
25
+ update(message: InputType): Md5;
26
+ hmac: {
27
+ (key: InputType, message: InputType): string;
28
+ hex(key: InputType, message: InputType): string;
29
+ array(key: InputType, message: InputType): number[];
30
+ digest(key: InputType, message: InputType): number[];
31
+ arrayBuffer(key: InputType, message: InputType): ArrayBuffer;
32
+ buffer(key: InputType, message: InputType): ArrayBuffer;
33
+ base64(key: InputType, message: InputType): string;
34
+ create(key: InputType): HmacMd5;
35
+ update(key: InputType, message: InputType): HmacMd5;
36
+ };
37
+ }
38
+
39
+ declare const md5: Md5Static;
40
+ export default md5;
package/src/md5.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * [js-md5]{@link https://github.com/emn178/js-md5}
3
- *
3
+ *
4
4
  * @version 0.8.3
5
5
  * @license MIT
6
- *
6
+ *
7
7
  * Copyright 2014-2023 Chen, Yi-Cyuan
8
8
  *
9
9
  * Permission is hereby granted, free of charge, to any person obtaining
@@ -160,9 +160,9 @@ var createOutputMethod = function (outputType) {
160
160
  */
161
161
  var createMethod = function () {
162
162
  var method = createOutputMethod('hex');
163
- if (NODE_JS) {
164
- method = nodeWrap(method);
165
- }
163
+ // if (NODE_JS) {
164
+ // method = nodeWrap(method);
165
+ // }
166
166
  method.create = function () {
167
167
  return new Md5();
168
168
  };
@@ -52,13 +52,13 @@ describe('AES Bridge Tests', async () => {
52
52
  }
53
53
 
54
54
  // Group 3: exact expected results from test_data["tests"]
55
- for (const [idx, test] of (json.tests || []).entries()) {
55
+ for (const [idx, test] of (json.decrypt || []).entries()) {
56
56
  const id = test.id || `case_${idx}`;
57
57
  const pass = test.passphrase;
58
58
 
59
- let input = test.plaintext
60
- ? encoder.encode(test.plaintext)
61
- : fromHex(test.hex);
59
+ let input = test.hex
60
+ ? fromHex(test.hex)
61
+ : encoder.encode(test.plaintext);
62
62
 
63
63
  if (test['encrypted-cbc']) {
64
64
  cases.push({
@@ -15,13 +15,35 @@
15
15
  "5964d4f5bc127ed016cc471ba8250f05f707da12f8e5c85e733a2abe31a705ffd7a72fe5d4c40611aca98396dc123093c37340cd17f926b73be6753e9636e0ea"
16
16
  ]
17
17
  },
18
- "tests": [
18
+ "decrypt": [
19
19
  {
20
+ "id": "empty_text_passphrase",
21
+ "plaintext": "",
22
+ "passphrase": "",
23
+ "encrypted-cbc": "d70jWQQ168YjOSCtakpqFhcXAUAPbi73KdJyDiRNdgodKe5vBppGMKllMBJW60tjcGwyeo7hcboDFldqypZWLNA7ADToK8FXtuptS/OLjYo=",
24
+ "encrypted-gcm": "qmF/OmL/6ULDRhHQwCkx3yqNLklTFaetHVtMTt3gm1kxnn7C1xa/ym6fTrw=",
25
+ "encrypted-legacy": "U2FsdGVkX1+Cyk5t+UT/wksJJ0z8jZCtHUzOFSAZApY="
26
+ }, {
27
+ "id": "empty_text",
28
+ "plaintext": "",
29
+ "passphrase": "password",
30
+ "encrypted-cbc": "utx0Dv6PSUhWm4PBbqsNdJRRZkK1GbY1dfYNVmRzQ3BUnOqZ9gDEX+s9zdk+kGq1zcfl0COCBDIFTvKBexycFnETAQdxpyt5VjT3U77uBd4=",
31
+ "encrypted-gcm": "3Qdd65IVNQqZeq4l/eXPF/feAfSM0IRo8AI2cAPwgIHU/Jo2inyWgM7ZQvY=",
32
+ "encrypted-legacy": "U2FsdGVkX1/5VjIpUvI/B+A2hytUI1WyBwzYKPBxvGk="
33
+ }, {
34
+ "id": "empty_passphrase",
35
+ "plaintext": "The quick brown fox выпей чаю 中文测试 𝔣𝔯𝔞𝔨𝔱𝔲𝔯 😉😌😍😘",
36
+ "passphrase": "",
37
+ "encrypted-cbc": "2G2EcdfmP0z0W0Nq4ncfVrMY4zVJv+Lc/7FG3jvoGjWm0evukfgCrUUzHOTu4X/6suTODLJXxVWCDYlzGV/oVpWMlJ+P/+zNTCwOBn+iO82TC9OUnZNIzbjFV7/KdN1y0xDWsmtsj0j84ov9UUDCLCO5yZhmG/Mpdm+W7NT3bP+43RoB0YxWSVfEPVizD/kU/wY/qxGsRnjUJ9rzTQG2N8vwrqx4RNRwJC8l5p1TJkU=",
38
+ "encrypted-gcm": "XxVvYTOuKGxwL/husHQf6p8Y103z+dXmCzUmpWPVIETy6rY0EiiH8FoLikeC4xig3XwuwJ+gkNWbwUkhOHGiapEz5oBGbmVpftHuTTZisqVuQAXXkrieTl9hbWXlL7iim1C7d9oAvvV5523HhqQbo1VRnjAHr5JRP0MYuiK9RqBha6ziIzuSTloVWbg=",
39
+ "encrypted-legacy": "U2FsdGVkX1+LTVSEG1YzsTq8wc232QWdtQdmt42OfAARlKg7Fm/EDNQBR7s2jMtjYDBJUHkp0csyoE1HgUQ6zY1Xr2HbR8qDZ13oTad5qJj1o/ZsXFbgaqHjSHh43y2YvKoDJmtpfxkJFaI9Z5PCHtBzOFZLo+XFuOLSLeJtVOE="
40
+ }, {
20
41
  "id": "plaintext_utf8",
21
42
  "plaintext": "The quick brown fox выпей чаю 中文测试 𝔣𝔯𝔞𝔨𝔱𝔲𝔯 😉😌😍😘",
22
43
  "passphrase": "áuhêüÖÕ0H_{³¹ßLè\\8ÉñïäzH`&[BÔͨåg_!±Ýp+ãÏÜì 😍",
23
44
  "encrypted-cbc": "JELXLWOrwjopsFKiEV11L68Ta5Mz9adzNNewgyzITPeZ3CQ5a/00FSDTPJ+tbGH9DagB04LNoIriC2o/etpkE1DkFwJZk0jXN12bFGwWJZPZy15T9JxDL/BOHiiycICoTGAToH6XyOuc5vXHsZwFSn/1QL5+xaR2GPbL/wWKnmckDj+W5hhvh2R4Z7V9dQmVc9PSCCYnbn8vymiFLc7deAxcpjg45+6hONn80GJ8fNg=",
24
- "encrypted-gcm": "W4et1smZeF2JGtYjzkdHbAvaqXb+K1nzzcfY2bTTpgsbPw4TmBFc0I5iwgWoU0hGC9ZuB/UcS1huxOHZe7WqR4Ol/FyNhjDB9bTobZCigAC4Q7GVpjiNCZYwouNfL7R/Nn4GyPjOGLY+E/9QisBv0tyfP4rLzFHzZzRmxb0skuT5IqP2lox/sBI4+YI="
45
+ "encrypted-gcm": "W4et1smZeF2JGtYjzkdHbAvaqXb+K1nzzcfY2bTTpgsbPw4TmBFc0I5iwgWoU0hGC9ZuB/UcS1huxOHZe7WqR4Ol/FyNhjDB9bTobZCigAC4Q7GVpjiNCZYwouNfL7R/Nn4GyPjOGLY+E/9QisBv0tyfP4rLzFHzZzRmxb0skuT5IqP2lox/sBI4+YI=",
46
+ "encrypted-legacy": "U2FsdGVkX18NhLfGwJ8bJzqrUIyGgE5dl4bi486LLXNPZrQvHGnATGrqL2Jy9a04c+ockLNDQvJ/Q4RepPzX9z/Igim+ziV6JAODOjAtov1LTj2eXw9mD1oxUpMNcohf+uOKxar9dSPVf0lj+qU+DF7DXf78WfIG9cnjTV6CqHo="
25
47
  }, {
26
48
  "id": "binary_data",
27
49
  "hex": "5964d4f5bc127ed016cc471ba8250f05f707da12f8e5c85e733a2abe31a705ffd7a72fe5d4c40611aca98396dc123093c37340cd17f926b73be6753e9636e0ea",
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "moduleResolution": "bundler",
4
+ "allowJs": true,
5
+ "esModuleInterop": true,
6
+ "allowSyntheticDefaultImports": true,
7
+ "target": "ES2020",
8
+ "module": "ESNext",
9
+ "lib": ["ES2020", "DOM"],
10
+ "skipLibCheck": true,
11
+ "noEmit": true
12
+ },
13
+ "include": [
14
+ "src/**/*.js",
15
+ "src/**/*.d.ts"
16
+ ]
17
+ }