本站首页    管理页面    写新日志    退出


«September 2025»
123456
78910111213
14151617181920
21222324252627
282930


公告
================

注会练习软件
http://www.cpasoft.com.cn
我的注会软件官网

http://blog.163.com/abc7105@126/

 

 


哈哈,热爱快“过气”的DELPHI


我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:注册会计师(注会)练习软件
日志总数:398
评论数量:116
留言数量:27
访问次数:3269756
建立时间:2005年6月6日




[delpih编程]公司用字符串加密解密函数(delphi版)【转贴】
软件技术

吕向阳 发表于 2009/4/18 17:41:10

公司用字符串加密函数(delphi版)(2006-07-07 14:29:59) {字符串加密解密 2005.04.12 Wahnch Yeh}unit uEncrypt;interfaceusessysutils;constEncrypt_Const = $3412;function Encrypt(const S: String; Key: Word): String;function Decrypt(const S: String; Key: Word): String;implementationfunction TransChar(AChar: Char): Integer;beginif ((Achar>='0') and (Achar<='9')) thenresult := Ord(AChar) - Ord('0')elseResult := 10 + Ord(AChar) - Ord('A');end;function StrToHex(AStr: string): string;varI : Integer;beginResult := '';For I := 1 to Length(AStr) dobeginResult := Result + Format('%2x', [Byte(AStr[I])]);end;I := Pos(' ', Result);While I <> 0 dobeginResult[I] := '0';I := Pos(' ', Result);end;end;function HexToStr(AStr: string): string;varI : Integer;Charvalue: Word;beginResult := '';For I := 1 to Trunc(Length(Astr)/2) dobeginResult := Result + ' ';Charvalue := TransChar(AStr[2*I-1])*16 + TransChar(AStr[2*I]);Result[I] := Char(Charvalue);end;end;function Encrypt(const S: String; Key: Word): String;varI : Integer;beginResult := S;for I := 1 to Length(S) dobeginResult[I] := char(byte(S[I]) xor (Key shr 8));Key := (byte(Result[I]) + Key) * $C1 + $C2;if Result[I] = Chr(0) then Result[I] := S[I];end;Result := StrToHex(Result);end;function Decrypt(const S: String; Key: Word): String;varI: Integer;S1: string;beginS1 := HexToStr(S);Result := S1;for I := 1 to Length(S1) dobeginif char(byte(S1[I]) xor (Key shr 8)) = Chr(0) thenbeginResult[I] := S1[I];Key := (byte(Chr(0)) + Key) * $C1 + $C2; //±V¤Key的正取ば浴 endelse beginResult[I] := char(byte(S1[I]) xor (Key shr 8));Key := (byte(S1[I]) + Key) * $C1 + $C2;end;end;end;end.


阅读全文(1015) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.031 second(s), page refreshed 144788206 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号