把数据加密后再通过套接字函数发送出去 接收方收到后再解密
所谓加密就是 对数据隔位取反 再把数据调整位置(第一位和第二位对调,第三和第四 等等)。但是我刚学delphi 不是怎么把字符串数据转为二进制 请高手给出加密解密代码
所谓加密就是 对数据隔位取反 再把数据调整位置(第一位和第二位对调,第三和第四 等等)。但是我刚学delphi 不是怎么把字符串数据转为二进制 请高手给出加密解密代码
解决方案 »
- ADOQuery 修改记录怎么变成新增加记录???
- ADOQuery查询的返回值
- 关于画面分割,请大家帮帮忙..
- 誰說DELPHI沒有前途了?-----為DELPHI的將來而貢獻力量
- FastReport代码邦定对象不起作业?在线等!
- 想设一个共用变量,用两个应用程序(.EXE),一个应用程序给共用变量赋值,另一个应用程序可以取出共用变量的值。
- 把Ole文件转到TMemoryStream为什么还是不能存入数据库??
- 求助:vista和win7中imm32.dll相关的大部分API失效了,怎么办?
- mouse的位置如何确定?
- 请问哪里有下介绍server页控件的书可以下载?
- 做个进销存系统的大侠进来看看 关于数据库设计的问题
- 现金购买“化工类”进销存,erp管理系统,请进~~~~~
s:string;
buf:pchar;
buf1:array of byte;
begin
s:='hihisdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdf';
getmem(buf,length(s));
setlength(buf1,length(s));
hextobin(pchar(s),buf,length(s));
copymemory(@buf1[0],buf,length(s));
showmessage(inttostr(buf1[0]));
freemem(buf);
end;取反
var
a,b:byte;
begin
a:=$f0;
b:=not a;
showmessage(inttostr(b));隔位取反和移位的要求比较难以实现,等高手来吧。
var
T: Byte;
P1, P2: PByte;
begin
P1 := PByte(@Buf);
P2 := PByte(PChar(@Buf) + 1);
while Size > 0 do
begin
T := P2^;
P2^ := not P1^;
P1^ := not T;
Inc(P1, 2);
Inc(P2, 2);
Dec(Size, 2);
end;
end;procedure Decode(var Buf; Size: Integer);
begin
Encode(Buf, Size);
end;
b:= a or ((not a)and 85)
b:= (a and 170) or ((not a)and 85)
CHR也是字节值,所以有ORD()可以转换起ASCII值
//==================================================procedure TForm1.Button1Click(Sender: TObject);
var
a,b:integer;
begin
a:=100;
b:=(a and 170) or ((not a)and 85) ;
edit1.Text :=inttostr(b);
end;
var b : byte;
begin
b := a xor 85; //隔位取反
Result := (b shl 1) and 170 or (b shr 1) and 85; //邻位对调
end;