繁体   English   中英

将char转换为char例如加密

[英]convert char to char such as encryption

如何进行简单的加密解密?
2个make make box和一个项目中的按钮,然后我在editbox1编写一些editbox1 ,然后在editbox2button1在此类设置中生成一些键。

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的简单转换.. 因此,请进行简单的替换密码和解密

这是一个简单的替换密码

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;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM