Skip to content

Commit d1e7912

Browse files
authored
V3.1.0
V3.1.0
2 parents 1a8c933 + 2397fa0 commit d1e7912

11 files changed

Lines changed: 585 additions & 303 deletions

File tree

DEPLOY.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Abracadabra.DECRYPT = "DECRYPT";
100100
强制解密
101101
102102
*/
103-
Abra.Input_Next(input,mode,key,q,r)
103+
Abra.Input_Next(input,mode,key,q,r,p,l)
104104
```
105105

106106
第一个参数 `input` 接受两种类型的输入,分别是 `String``Uint8Array`,这是此前在实例化的时候指定的输入类型。
@@ -113,11 +113,17 @@ Abra.Input_Next(input,mode,key,q,r)
113113

114114
如果指定了错误的密码,那么在解码/解密数据校验过程中会抛出错误。
115115

116-
第四个参数 `q` 接受布尔值的输入,如果传入 `true`,则加密结果中将不含标点符号,解密时可以忽略这个参数。
116+
第四个参数 `q` 接受布尔值的输入,默认为 `true`。如果传入 `false`,则加密结果中将不含标点符号,解密时可以忽略这个参数。
117117

118-
第五个参数 `r` 接受整数值的输入,最小值`0`,最大值`100`,超过 100 的输入将会报错。输入值越大,句式选择算法的随机性越大;输入值为 0 时,句式选择步骤将只选择载荷字最多的那个
118+
第五个参数 `r` 接受整数值的输入,默认为`50`最小值`0`,最大值`100`,超过 100 的输入将会报错。输入值越大,载荷量选择算法的随机性越大;输入值为 0 时,句式选择步骤将只选择载荷字较多的那个。解密时可以忽略这个参数
119119

120-
在无错误的情况下, `Input()` 函数的返回值通常是 `0`
120+
第六个参数 `p` 接受布尔值的输入,默认为 `false`。如果传入 `true`,则加密结果会优先使用骈文句式,呈现四字到五字一组的对仗格律,这有助于减少密文的总体长度。解密时可以忽略这个参数。
121+
122+
第七个参数 `l` 接受布尔值的输入,默认为 `false`。如果传入 `true`,则加密结果会优先使用逻辑句式,呈现强论述类逻辑风格。解密时可以忽略这个参数。
123+
124+
`p``l` 不能同时指定为 `true`,否则会抛出错误。
125+
126+
在无错误的情况下, `Input_Next()` 函数的返回值通常是 `0`
121127

122128
#### Output()
123129

@@ -150,14 +156,16 @@ let Result = Abra.Output() //获取输出
150156
```json
151157

152158
{
153-
"method":"", // NEXT | OLD //前者是仿真加密,后者是传统加密
159+
"method":"", // NEXT | OLD
154160
"inputType":"", // TEXT | UINT8
155161
"outputType":"", // TEXT | UINT8
156162
"input":"", //输入的数据,如果是TEXT请直接输入纯文本,如果是任意字节,请输入Base64编码字符串
157163
"mode":"", // ENCRYPT | DECRYPT | AUTO // AUTO 仅在 method 指定 OLD 时合法
158-
"key":"", //加密密钥,一个字符串,不可缺省,JavaScript实现的默认值为 ABRACADABRA
159-
"q":bool, //OLD模式下,决定是否去除标志位 | NEXT模式下,决定输出密文是否有标点符号
164+
"key":"", //加密密钥,一个字符串 //如果缺省,自动使用默认值
165+
"q":bool, //OLD模式下,决定是否添加标志位 | NEXT模式下,决定输出密文是否有标点符号
160166
"r":number, //仅NEXT模式下需要:算法的随机程度,越大随机性越强,默认 50,最大100,超过100将会出错;
167+
"p":bool, //仅NEXT模式下需要:尽可能使用对仗的骈文句式; 与逻辑句式冲突
168+
"l":bool, //仅NEXT模式下需要:尽可能使用逻辑句式; 与骈文句式冲突
161169

162170
}
163171

@@ -171,7 +179,7 @@ let Result = Abra.Output() //获取输出
171179

172180
```shell
173181

174-
echo '{"method":"NEXT","mode":"ENCRYPT","inputType":"TEXT","outputType":"TEXT","input":"测试","key":"ABRACADABRA","q":true,"r":50}' | wasmtime abracadabra-cn.wasm
182+
echo '{"method":"NEXT","mode":"ENCRYPT","inputType":"TEXT","outputType":"TEXT","input":"愿青空的祝福,与我的羽翼同在","key":"ABRACADABRA","q":true,"r":50,"p":false,"l":false}' | wasmtime abracadabra-cn.wasm
175183

176184
```
177185

JavyInputAppendix.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"key":"", //加密密钥,一个字符串 //如果缺省,自动使用默认值
2727
"q":bool, //OLD模式下,决定是否添加标志位 | NEXT模式下,决定输出密文是否有标点符号
2828
"r":number, //仅NEXT模式下需要:算法的随机程度,越大随机性越强,默认 50,最大100,超过100将会出错;
29+
"p":bool, //仅NEXT模式下需要:尽可能使用对仗的骈文句式; 与逻辑句式冲突
30+
"l":bool, //仅NEXT模式下需要:尽可能使用逻辑句式; 与骈文句式冲突
2931
3032
}
3133
@@ -63,7 +65,15 @@ function index(input) {
6365
if (input.method == "NEXT") {
6466
if (input.inputType == "TEXT") {
6567
let Abra = new Abracadabra(input.inputType, input.outputType);
66-
Abra.Input_Next(input.input, input.mode, input.key, input.q, input.r);
68+
Abra.Input_Next(
69+
input.input,
70+
input.mode,
71+
input.key,
72+
input.q,
73+
input.r,
74+
input.p,
75+
input.l
76+
);
6777
let Output = Abra.Output();
6878
if (input.outputType == "UINT8") {
6979
Output = uint8ArrayToBase64(Output);
@@ -72,7 +82,15 @@ function index(input) {
7282
} else if (input.inputType == "UINT8") {
7383
let Abra = new Abracadabra(input.inputType, input.outputType);
7484
let UINT8In = base64ToUint8Array(input.input);
75-
Abra.Input_Next(UINT8In, input.mode, input.key, input.q, input.r);
85+
Abra.Input_Next(
86+
UINT8In,
87+
input.mode,
88+
input.key,
89+
input.q,
90+
input.r,
91+
input.p,
92+
input.l
93+
);
7694
let Output = Abra.Output();
7795
if (input.outputType == "UINT8") {
7896
Output = uint8ArrayToBase64(Output);

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ import { Abracadabra } from "abracadabra-cn";
9393

9494
```shell
9595

96-
echo '{"method":"NEXT","mode":"ENCRYPT","inputType":"TEXT","outputType":"TEXT","input":"测试","key":"ABRACADABRA","q":true,"r":50}' | wasmtime abracadabra-cn.wasm
96+
echo '{"method":"NEXT","mode":"ENCRYPT","inputType":"TEXT","outputType":"TEXT","input":"愿青空的祝福,与我的羽翼同在","key":"ABRACADABRA","q":true,"r":50,"p":false,"l":false}' | wasmtime abracadabra-cn.wasm
9797

9898
```
9999

Lines changed: 80 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
return this._attachShadow({ mode: "open" });
1212
};
1313
</script>
14-
<script type="module" crossorigin src="./assets/index-Y14zB65A.js"></script>
14+
<script type="module" crossorigin src="./assets/index-DzyBey0l.js"></script>
1515
<link rel="stylesheet" crossorigin href="./assets/index-kawgJGu9.css">
1616
<link rel="manifest" href="./manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="./registerSW.js"></script></head>
1717
<body>

docs/sw.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "abracadabra-cn",
33
"description": "Use Chinese to Encode Everything",
44
"private": false,
5-
"version": "3.0.11",
5+
"version": "3.1.0",
66
"main": "./dist/abracadabra-cn.js",
77
"type": "module",
88
"scripts": {

src/javascript/main.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,18 @@ export class Abracadabra {
184184
* @param{string}key 指定密钥,默认是 ABRACADABRA;
185185
* @param{bool}q 指定是否为密文添加标点符号,默认 true/添加;
186186
* @param{int}r 密文算法的随机程度,越大随机性越强,默认 50,最大100,超过100将会出错;
187+
* @param{bool}p 指定是否强制生成骈文密文,默认 false;
188+
* @param{bool}l 指定是否强制生成逻辑密文,默认 false;
187189
*/
188-
Input_Next(input, mode, key = "ABRACADABRA", q = true, r = 50) {
190+
Input_Next(
191+
input,
192+
mode,
193+
key = "ABRACADABRA",
194+
q = true,
195+
r = 50,
196+
p = false,
197+
l = false
198+
) {
189199
if (this.#input == Abracadabra.UINT8) {
190200
//如果指定输入类型是UINT8
191201
if (Object.prototype.toString.call(input) != "[object Uint8Array]") {
@@ -194,7 +204,7 @@ export class Abracadabra {
194204
if (mode == Abracadabra.ENCRYPT) {
195205
let Nextinput = new Object();
196206
Nextinput.output = input;
197-
this.#res = Util_Next.enMap(Nextinput, key, q, r);
207+
this.#res = Util_Next.enMap(Nextinput, key, q, r, p, l);
198208
} else if (mode == Abracadabra.DECRYPT) {
199209
let Nextinput = new Object();
200210
Nextinput.output = input;
@@ -209,7 +219,7 @@ export class Abracadabra {
209219
let Nextinput = new Object();
210220
Nextinput.output = Util.stringToUint8Array(input);
211221
if (mode == Abracadabra.ENCRYPT) {
212-
this.#res = Util_Next.enMap(Nextinput, key, q, r);
222+
this.#res = Util_Next.enMap(Nextinput, key, q, r, p, l);
213223
} else if (mode == Abracadabra.DECRYPT) {
214224
this.#res = Util_Next.deMap(Nextinput, key);
215225
}

0 commit comments

Comments
 (0)