求一段加密解密代码,只要能对字符串进行简单的加密解密就行。

wushenjian 2002-11-22 05:14:06
如题
...全文
64 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
DelUser 2002-11-25
  • 打赏
  • 举报
回复
用 strongq(火血狼) 的应该就可以了!
Linux2001 2002-11-25
  • 打赏
  • 举报
回复
用CRC32也可以,比较好的方法是使用DES或者是PGP,这些网上都有资料
wushenjian 2002-11-25
  • 打赏
  • 举报
回复
楼上各位的方案都没有行通,还是我自己做个简单的,就是把各个字符
转换成ASICC码,再加1,呵呵,能起到简单的信息屏蔽作用就行了。
散分吧。
wushenjian 2002-11-23
  • 打赏
  • 举报
回复
daniel007(添) :我没有收到,麻烦再发一次到wsj@huigu.net
strongq(火血狼) :这段代码运行到key:=(byte(s[i])+key)*fc1+fc2就
      会溢出,另外,key取值多少?
strongq 2002-11-22
  • 打赏
  • 举报
回复
以上摘自<<DELPHI斑竹答疑>>
strongq 2002-11-22
  • 打赏
  • 举报
回复
忘了说了上面的fc1,fc2为秘匙,可为任意整数常量,我用的是
fc1:=52845;
fc2:=22719;
strongq 2002-11-22
  • 打赏
  • 举报
回复
function ptom(const s:string;key:word):string;
var
i:byte;
begin
//result[0]:=s[0];
setlength(result,length(s));
for i:=1 to length(s) do
begin
result[i]:=char(byte(s[i])xor (key shr 8));
key:=(byte(result[i])+ key)*fc1+fc2;
end;
end;

function mtop(const s:string;key:word):string;
var
i:byte;
begin
setlength(result,length(s));
for i:=1 to length(s) do begin
result[i]:=char(byte(s[i])xor(key shr 8));
key:=(byte(s[i])+key)*fc1+fc2;
end;
end;
daniel007 2002-11-22
  • 打赏
  • 举报
回复
已发
wushenjian 2002-11-22
  • 打赏
  • 举报
回复
mrfanghansheng(***Rocket***) :
有没有对字符串加密解密的,简单点就行。
wushenjian 2002-11-22
  • 打赏
  • 举报
回复
laihecongxi(兴哥) :
你这段代码似乎有问题,很容易溢出。
wushenjian 2002-11-22
  • 打赏
  • 举报
回复
daniel007(添) :wsj@huigu.net
mrfanghansheng 2002-11-22
  • 打赏
  • 举报
回复
key 是密钥 例如 key:=35;
daniel007 2002-11-22
  • 打赏
  • 举报
回复
你的邮箱
laihecongxi 2002-11-22
  • 打赏
  • 举报
回复
短字符串的简单加密/解密 [摘录]
const
c1 = 52845;
c2 = 22719;
function Encrypt (const s: string; Key: Word) : string;
var
i : byte;
begin
Result[0] := s[0];
for i := 1 to length (s) do
begin
Result[i] := Char (byte (s[i]) xor (Key shr 8));
Key := (byte (Result[i]) + Key) * c1 + c2
end
end;

function Decrypt (const s: string; Key: Word) : string;
var
i : byte;
begin
Result[0] := s[0];
for i := 1 to length (s) do
begin
Result[i] := Char (byte (s[i]) xor (Key shr 8));
Key := (byte (s[i]) + Key) * c1 + c2
end
end;

mrfanghansheng 2002-11-22
  • 打赏
  • 举报
回复
最简单的异或运算……解密就是把程序再运行一次

function EncryptOrUnEncryptfiles(FileName: string;jor:boolean):boolean;
var
iFileHandle: Integer;
iFileLength: Integer;
Buffer: PChar;
i : integer;
cflag:boolean;
key:integer;
newfilename:string;
begin

if not fileexists(filename) then //若文件不存在则返回
begin
result:=false;
exit;
end;


iFileHandle := FileOpen(FileName, fmOpenRead);
iFileLength := FileSeek(iFileHandle,0,2);
FileSeek(iFileHandle,0,0);
Buffer := PChar(AllocMem(iFileLength + 1));
iFileLength := FileRead(iFileHandle, Buffer^, iFileLength);
FileClose(iFileHandle);
FileSeek(iFileHandle,0,0);

for i:=0 to iFileLength do //文件主体信息异或算法一次
begin
(Buffer+i)^:=chr(integer((Buffer+i)^) xor key);
end;

iFileHandle := FileCreate(FileName);
Filewrite(iFileHandle, Buffer^, iFileLength);
FileClose(iFileHandle);
freemem(Buffer);
result:=true;
end;
mircocheng 2002-11-22
  • 打赏
  • 举报
回复
我现在是想不起来了。心情坏透了。
你可以参考最近几期的电脑报。上面有 。

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧