yukichant 3.0.2 → 3.0.3
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/package.json +1 -1
- package/src/cli.js +1 -3
- package/src/machine-encrypt.js +14 -7
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
import getStdin from 'get-stdin'
|
|
3
3
|
import chant from './index.js'
|
|
4
4
|
import fs from 'fs'
|
|
5
|
-
|
|
6
|
-
const dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
7
|
-
const { version } = JSON.parse(fs.readFileSync(`${dirname}/../package.json`));
|
|
5
|
+
const { version } = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
8
6
|
|
|
9
7
|
import { Command } from 'commander/esm.mjs';
|
|
10
8
|
const program = new Command();
|
package/src/machine-encrypt.js
CHANGED
|
@@ -5,13 +5,21 @@ let toNumber = (list,input) => list[input]
|
|
|
5
5
|
let revToNumber = (list,input) => list.indexOf(input)
|
|
6
6
|
|
|
7
7
|
let encrypt = (uint8array,roter,refrector) => {
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
|
|
8
|
+
let phase_1, phase_2, phase_3;
|
|
9
|
+
let nextRotor = roter;
|
|
10
|
+
const ret = [];
|
|
11
11
|
|
|
12
|
-
let
|
|
12
|
+
for (let v of uint8array) {
|
|
13
|
+
phase_1 = toNumber(nextRotor,v);
|
|
14
|
+
phase_2 = toNumber(refrector,phase_1);
|
|
15
|
+
phase_3 = revToNumber(nextRotor,phase_2);
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
nextRotor = [ ...nextRotor.slice(1) , nextRotor[0] ];
|
|
18
|
+
|
|
19
|
+
ret.push(phase_3);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return ret;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
export default {
|
|
@@ -20,6 +28,5 @@ export default {
|
|
|
20
28
|
encrypt,
|
|
21
29
|
uint8ArrayEncrypt(uint8array) {
|
|
22
30
|
return this.encrypt(uint8array,this.default_roter,this.refrector);
|
|
23
|
-
}
|
|
31
|
+
},
|
|
24
32
|
}
|
|
25
|
-
|