如何做一个简单的加密解密?
2在项目中制作编辑框和一个按钮,然后用editbox1写一些东西,然后在editbox2中按button1生成这样的一些键。
a:= 1;b:= 2;c:= 3;d:= 4;e:= 5;f:= 6;g:= 7;h:= 8;i:= 9;j:= 0;k:= #;l:= $;m:=%;n:= ~;o:= *;
然后用符号说
a: = 1;意思是:a is 1 if at editbox2
字母(A)是数字1 (B)分段是数字2 (C)分段是数字3简单转换.所以做一个简单的替换密码和解密
发布于 2014-08-16 06:31:21
下面是一个简单的替换密码
const
CPlain = 'abcdefghijklmno';
CCrypt = '1234567890#$%~*';
function Transcode( const AStr, ALookupA, ALookupB : string ): string;
var
LIdx, LCharIdx : integer;
begin
// the result has the same length as the input string
SetLength( Result, Length( AStr ) );
// walk through the whole string
for LIdx := 1 to Length( AStr ) do
begin
// find position of char in LookupA
LCharIdx := Pos( AStr[LIdx], ALookupA );
// use the char from LookupB at the previous position
Result[LIdx] := ALookupB[LCharIdx];
end;
end;
function Encrypt( const AStr : string ) : string;
begin
// from plain text to crypt text
Result := Transcode( AStr, CPlain, CCrypt );
end;
function Decrypt( const AStr : string ) : string;
begin
// from crypt text to plain text
Result := Transcode( AStr, CCrypt, CPlain );
end;https://stackoverflow.com/questions/25337395
复制相似问题