Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions DEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Abracadabra.DECRYPT = "DECRYPT";
强制解密

*/
Abra.Input_Next(input,mode,key,q,r)
Abra.Input_Next(input,mode,key,q,r,p,l)
```

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

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

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

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

在无错误的情况下, `Input()` 函数的返回值通常是 `0`。
第六个参数 `p` 接受布尔值的输入,默认为 `false`。如果传入 `true`,则加密结果会优先使用骈文句式,呈现四字到五字一组的对仗格律,这有助于减少密文的总体长度。解密时可以忽略这个参数。

第七个参数 `l` 接受布尔值的输入,默认为 `false`。如果传入 `true`,则加密结果会优先使用逻辑句式,呈现强论述类逻辑风格。解密时可以忽略这个参数。

`p` 和 `l` 不能同时指定为 `true`,否则会抛出错误。

在无错误的情况下, `Input_Next()` 函数的返回值通常是 `0`。

#### Output()

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

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

}

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

```shell

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

```

Expand Down
22 changes: 20 additions & 2 deletions JavyInputAppendix.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"key":"", //加密密钥,一个字符串 //如果缺省,自动使用默认值
"q":bool, //OLD模式下,决定是否添加标志位 | NEXT模式下,决定输出密文是否有标点符号
"r":number, //仅NEXT模式下需要:算法的随机程度,越大随机性越强,默认 50,最大100,超过100将会出错;
"p":bool, //仅NEXT模式下需要:尽可能使用对仗的骈文句式; 与逻辑句式冲突
"l":bool, //仅NEXT模式下需要:尽可能使用逻辑句式; 与骈文句式冲突

}

Expand Down Expand Up @@ -63,7 +65,15 @@ function index(input) {
if (input.method == "NEXT") {
if (input.inputType == "TEXT") {
let Abra = new Abracadabra(input.inputType, input.outputType);
Abra.Input_Next(input.input, input.mode, input.key, input.q, input.r);
Abra.Input_Next(
input.input,
input.mode,
input.key,
input.q,
input.r,
input.p,
input.l
);
let Output = Abra.Output();
if (input.outputType == "UINT8") {
Output = uint8ArrayToBase64(Output);
Expand All @@ -72,7 +82,15 @@ function index(input) {
} else if (input.inputType == "UINT8") {
let Abra = new Abracadabra(input.inputType, input.outputType);
let UINT8In = base64ToUint8Array(input.input);
Abra.Input_Next(UINT8In, input.mode, input.key, input.q, input.r);
Abra.Input_Next(
UINT8In,
input.mode,
input.key,
input.q,
input.r,
input.p,
input.l
);
let Output = Abra.Output();
if (input.outputType == "UINT8") {
Output = uint8ArrayToBase64(Output);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import { Abracadabra } from "abracadabra-cn";

```shell

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

```

Expand Down
158 changes: 80 additions & 78 deletions docs/assets/index-Y14zB65A.js → docs/assets/index-DzyBey0l.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
return this._attachShadow({ mode: "open" });
};
</script>
<script type="module" crossorigin src="./assets/index-Y14zB65A.js"></script>
<script type="module" crossorigin src="./assets/index-DzyBey0l.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-kawgJGu9.css">
<link rel="manifest" href="./manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="./registerSW.js"></script></head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion docs/sw.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "abracadabra-cn",
"description": "Use Chinese to Encode Everything",
"private": false,
"version": "3.0.11",
"version": "3.1.0",
"main": "./dist/abracadabra-cn.js",
"type": "module",
"scripts": {
Expand Down
16 changes: 13 additions & 3 deletions src/javascript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,18 @@ export class Abracadabra {
* @param{string}key 指定密钥,默认是 ABRACADABRA;
* @param{bool}q 指定是否为密文添加标点符号,默认 true/添加;
* @param{int}r 密文算法的随机程度,越大随机性越强,默认 50,最大100,超过100将会出错;
* @param{bool}p 指定是否强制生成骈文密文,默认 false;
* @param{bool}l 指定是否强制生成逻辑密文,默认 false;
*/
Input_Next(input, mode, key = "ABRACADABRA", q = true, r = 50) {
Input_Next(
input,
mode,
key = "ABRACADABRA",
q = true,
r = 50,
p = false,
l = false
) {
if (this.#input == Abracadabra.UINT8) {
//如果指定输入类型是UINT8
if (Object.prototype.toString.call(input) != "[object Uint8Array]") {
Expand All @@ -194,7 +204,7 @@ export class Abracadabra {
if (mode == Abracadabra.ENCRYPT) {
let Nextinput = new Object();
Nextinput.output = input;
this.#res = Util_Next.enMap(Nextinput, key, q, r);
this.#res = Util_Next.enMap(Nextinput, key, q, r, p, l);
} else if (mode == Abracadabra.DECRYPT) {
let Nextinput = new Object();
Nextinput.output = input;
Expand All @@ -209,7 +219,7 @@ export class Abracadabra {
let Nextinput = new Object();
Nextinput.output = Util.stringToUint8Array(input);
if (mode == Abracadabra.ENCRYPT) {
this.#res = Util_Next.enMap(Nextinput, key, q, r);
this.#res = Util_Next.enMap(Nextinput, key, q, r, p, l);
} else if (mode == Abracadabra.DECRYPT) {
this.#res = Util_Next.deMap(Nextinput, key);
}
Expand Down
Loading