关于Encode64加密算法在数据量大时很慢的问题?

znhyz1 znhyz1 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
方法:function Encode64(const test:string): string;
test量大时算法效率很低,需要几分钟才运算完。。。

function Encode64(const test:string): string;
var
s, s1: string;
i, p, len, n, Addnum: integer;

begin
result := '';

S := '';
for i := 1 to length(test) do
S := S + IntToHex(Ord(test[I]), 2);
//将字符串的十六进制数以字符串的形式表示出来
case (length(s) mod 3) of
0: addnum := 0;
1:
begin
s := s + '00';
addnum := 2;
end;
2:
begin
s := s + '0';
addnum := 1;
end;
else
addnum := 0;
end;
len := length(s) div 3;
for i := 1 to len do
begin
s1 :=Midstr(S, i*3-2,3);
p := strtoint('$' + s1);
n := p div 64;
result := result + basetable[n+1];
n := p mod 64;
result := result + basetable[n+1];
end;
if addnum = 1 then
result := result + '==';
if addnum = 2 then
result[length(result)] := '=';
end;
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部