Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor issue fixes. #6

Merged
merged 4 commits into from
Oct 30, 2024
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Abracadabra 还在积极开发中,这里是一些注意事项。

项目在 Windows 11 和 Ubuntu 22.04 LTS 上通过了编译测试。

在嵌入式平台(armv7a, armv8a)上通过了运行测试。

### 已知问题

#### 处理文件耗时指数级增加
Expand All @@ -81,7 +83,7 @@ Abracadabra 还在积极开发中,这里是一些注意事项。

原则上不能以牺牲随机性为代价换取执行速度,且本项目之目的并不是将文件转换为上百万个汉字,故搁置该问题。

小于 100kb 的文件均能在可控时间内得到处理。
小于 100kb 的文件均能在可控时间内得到处理。

#### 密本随机性不足

Expand All @@ -97,6 +99,10 @@ Abracadabra 还在积极开发中,这里是一些注意事项。
- [cppcodec](https://github.com/tplgy/cppcodec)
- [CLI11](https://github.com/CLIUtils/CLI11)

另外,请确保您的环境中安装了 C++11 标准库。

本项目并不复杂,推荐直接用指令调用 g++ 进行构建。如果您愿意,也可以尝试 CMake。

## 细节

### 加密实现
Expand Down
23 changes: 12 additions & 11 deletions src/abracadabra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ string enMap(PreCheckResult input,bool forceLink,bool forceBase64,bool forceDire
}
}
else if(q==1){ // 第二次大循环插入加密标志位


vector<int> AvailPos;
AvailPos.resize(max(PosToInset.size(),Avoid.size()));

Expand Down Expand Up @@ -559,18 +561,17 @@ string GetLinkCryptedText(string text){//查表,检查是否有任何预配置
s1 = el.key();
if(s.find(s1) != string::npos){//找到关键词
el.value().get_to(CipherArray);

//返回密本中的随机字符
RandIndex = dist(mt_r) % CipherArray.size(); //随机获取一个下标
int i = 0 ;
for (auto it : Map_Obj["link"][s1]){
if (i == RandIndex){//找到下标
s2 = (string)it;
break;
}
i++;
}
while(s.find(s1)<s.size()){
//返回密本中的随机字符
RandIndex = dist(mt_r) % CipherArray.size(); //随机获取一个下标
int i = 0 ;
for (auto it : Map_Obj["link"][s1]){
if (i == RandIndex){//找到下标
s2 = (string)it;
break;
}
i++;
}
int pos = s.find(s1);
s.replace(pos, s1.size(), s2);
}
Expand Down
21 changes: 10 additions & 11 deletions src/abracadabra_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,18 +558,17 @@ string GetLinkCryptedText(string text){//查表,检查是否有任何预配置
s1 = el.key();
if(s.find(s1) != string::npos){//找到关键词
el.value().get_to(CipherArray);

//返回密本中的随机字符
RandIndex = dist(mt_r) % CipherArray.size(); //随机获取一个下标
int i = 0 ;
for (auto it : Map_Obj["link"][s1]){
if (i == RandIndex){//找到下标
s2 = (string)it;
break;
}
i++;
}
while(s.find(s1)<s.size()){
//返回密本中的随机字符
RandIndex = dist(mt_r) % CipherArray.size(); //随机获取一个下标
int i = 0 ;
for (auto it : Map_Obj["link"][s1]){
if (i == RandIndex){//找到下标
s2 = (string)it;
break;
}
i++;
}
int pos = s.find(s1);
s.replace(pos, s1.size(), s2);
}
Expand Down