yukichant 3.0.2 → 3.0.5
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/.github/workflows/app-test.yml +57 -0
- package/README.md +5 -17
- package/data/meisi.json +1 -0
- package/doc/develop.md +20 -0
- package/package.json +1 -1
- package/src/cli.js +1 -3
- package/src/machine-encrypt.js +14 -7
- package/.github/workflows/jest-test.yml +0 -26
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Node CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
jest:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [ 12.x, 14.x, 16.x ]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- run: node -v
|
|
18
|
+
- uses: actions/checkout@v2
|
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
+
uses: actions/setup-node@v2
|
|
21
|
+
with:
|
|
22
|
+
node-version: ${{ matrix.node-version }}
|
|
23
|
+
- run: node -v
|
|
24
|
+
- run: npm ci
|
|
25
|
+
- run: npm test
|
|
26
|
+
|
|
27
|
+
test-on-volta:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
|
|
30
|
+
strategy:
|
|
31
|
+
matrix:
|
|
32
|
+
node-version: [ 12.x, 14.x, 16.x ]
|
|
33
|
+
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v1
|
|
36
|
+
- uses: volta-cli/action@v1
|
|
37
|
+
with:
|
|
38
|
+
node-version: ${{ matrix.node-version }}
|
|
39
|
+
|
|
40
|
+
- run: node -v
|
|
41
|
+
- uses: actions/checkout@v2
|
|
42
|
+
|
|
43
|
+
- name: install yukichant on local
|
|
44
|
+
run: |
|
|
45
|
+
npm install
|
|
46
|
+
npm install -g ../yukichant
|
|
47
|
+
|
|
48
|
+
- name: mkdir sandbox
|
|
49
|
+
run: mkdir -p ./exec_dir
|
|
50
|
+
|
|
51
|
+
- name: check cli path
|
|
52
|
+
run: which chant
|
|
53
|
+
working-directory: ./exec_dir
|
|
54
|
+
|
|
55
|
+
- run: chant
|
|
56
|
+
working-directory: ./exec_dir
|
|
57
|
+
|
package/README.md
CHANGED
|
@@ -28,25 +28,13 @@ $ chant
|
|
|
28
28
|
水面も灰塵に蒼穹を抗え。
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Documentation for Developers
|
|
32
|
+
[develop](/doc/develop.md)
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
execute command
|
|
39
|
-
```bash
|
|
40
|
-
## run encode
|
|
41
|
-
$ npm run dev unko
|
|
42
|
-
## run decode
|
|
43
|
-
$ npm run dev unko | npm run dev -- -d
|
|
44
|
-
```
|
|
34
|
+
## Thanks
|
|
35
|
+
I named "yukichant" by Nagato Yuki-chan + chant .
|
|
36
|
+
because I want to chant magic words like her.
|
|
45
37
|
|
|
46
38
|
## LICENSE
|
|
47
39
|
Apache-2.0
|
|
48
40
|
|
|
49
|
-
## Thanks
|
|
50
|
-
I named "yukichant" by Nagato Yuki-chan + chant .
|
|
51
|
-
becouse I want to chant magic words like her.
|
|
52
|
-
|
package/data/meisi.json
CHANGED
package/doc/develop.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Develop
|
|
2
|
+
---
|
|
3
|
+
|
|
4
|
+
## install dependency
|
|
5
|
+
```bash
|
|
6
|
+
$ npm install
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## execute command
|
|
10
|
+
```bash
|
|
11
|
+
## run encode
|
|
12
|
+
$ npm run dev unko
|
|
13
|
+
## run decode
|
|
14
|
+
$ npm run dev unko | npm run dev -- -d
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## generate meisi.json
|
|
18
|
+
```bash
|
|
19
|
+
$ ./raw_data/meisi_json_generator
|
|
20
|
+
```
|
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(new URL('../package.json', import.meta.url), '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
|
-
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Node CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
build:
|
|
10
|
-
name: build
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
|
|
13
|
-
strategy:
|
|
14
|
-
matrix:
|
|
15
|
-
node-version: [ 12.x, 14.x, 16.x ]
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- run: node -v
|
|
19
|
-
- uses: actions/checkout@v2
|
|
20
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
-
uses: actions/setup-node@v2
|
|
22
|
-
with:
|
|
23
|
-
node-version: ${{ matrix.node-version }}
|
|
24
|
-
- run: node -v
|
|
25
|
-
- run: npm ci
|
|
26
|
-
- run: npm test
|