怎样合并字符串?

jakegood 2003-09-11 05:16:28
我取了硬盘的ID号然后用ORD得出ASCCII码,结果是175436034055315314175,我嫌他有点多了,想合并一下,也就是让第一位和第三位相加,第二位和第四位相加,以此类推,得出来的结果在加一次。

还有,怎么把刚才得出的结果,用比较好的数学公式给加个密,做注册码。

...全文
128 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
hcjhjy 2003-09-14
  • 打赏
  • 举报
回复
用copy可以得到你的答案
walkmangood 2003-09-14
  • 打赏
  • 举报
回复
用MD5
walkmangood 2003-09-13
  • 打赏
  • 举报
回复
d
coreblood 2003-09-13
  • 打赏
  • 举报
回复
MD5啊好用

用完在移一移

呵呵~~
sy_315 2003-09-13
  • 打赏
  • 举报
回复
其实不用这么麻烦,左移,右移就可以了
h2yang 2003-09-13
  • 打赏
  • 举报
回复
取硬盘物理序列号就不会因为格盘而改变ID了.
minizhuxianchun 2003-09-13
  • 打赏
  • 举报
回复
function Chang(s: string): string;
var
i,n,m: byte;
a: array of byte;
s1: string;
begin
s1:='';
n:=length(s);
getmem(a,n);
for i:=1 to n do
a[i]:=Integr(s[i]);
if (n mod 2)=0 then
begin
m:=n div 2;
for i:=1 to (n div 2) do
a[i]:=a[i]+a[i+2];
end
else
begin
m:=(n div 2)+1;
for i:=1 to (n div 2)+1 do
begin
if i<=(n div 2) then
a[i]:=a[i]+a[i+2]
else
a[i]:=a[i];
end;
end;
for i:=1 to m do
s1:=s1+String(a[i]);
result:=s1;
end;
walkmangood 2003-09-12
  • 打赏
  • 举报
回复
其实加密算法有很多种,全部是数学公式的方式,你可以自己编写一个
mingjunlee 2003-09-12
  • 打赏
  • 举报
回复
up
mingjunlee 2003-09-12
  • 打赏
  • 举报
回复
关注..............
IORILI 2003-09-12
  • 打赏
  • 举报
回复
我觉得也有点像加密算法,帮你up
windindance 2003-09-12
  • 打赏
  • 举报
回复
找个MD5加密算法即可吧。
mysqlcom 2003-09-12
  • 打赏
  • 举报
回复
函数形式


Function JoinString(strInput:string):string;
var
strSource,strDes:string;
int1,int2,int3,int4:integer;
arrDes:array of string;
i,j,k,x:integer;
begin
strSource:=strInput;
i:=0;j:=0;k:=0;x:=0;
int1:=0;int2:=0;int3:=0;int4:=0;
i:=length(strSource);
if i mod 4=0 then begin
for k:=0 to (i div 4)-1 do begin
int1:=strtoint(strSource[k*4+1]);
int2:=strtoint(strSource[k*4+2]);
int3:=strtoint(strSource[k*4+3]);
int4:=strtoint(strSource[k*4+4]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
end
else begin
j:=i mod 4;
for k:=0 to (i div 4)-1 do begin
int1:=strtoint(strSource[k*4+1]);
int2:=strtoint(strSource[k*4+2]);
int3:=strtoint(strSource[k*4+3]);
int4:=strtoint(strSource[k*4+4]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;

int1:=0;int2:=0;int3:=0;int4:=0;
x:=k*4+1;
if (x)<=i then
int1:=strtoint(strSource[x]);
if (x+1)<=i then
int2:=strtoint(strSource[x+1]);
if (x+2)<=i then
int3:=strtoint(strSource[x+2]);
if (x+3)<=i then
int4:=strtoint(strSource[x+3]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
Result:=strDes;
end;
mysqlcom 2003-09-12
  • 打赏
  • 举报
回复
请参照下面的过程,改造成函数即可。
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;

type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
var
strSource,strDes:string;
int1,int2,int3,int4:integer;
arrDes:array of string;
i,j,k,x:integer;
begin
strSource:=memo1.Text;
i:=0;j:=0;k:=0;x:=0;
int1:=0;int2:=0;int3:=0;int4:=0;
i:=length(strSource);
if i mod 4=0 then begin
for k:=0 to (i div 4)-1 do begin
int1:=strtoint(strSource[k*4+1]);
int2:=strtoint(strSource[k*4+2]);
int3:=strtoint(strSource[k*4+3]);
int4:=strtoint(strSource[k*4+4]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
end
else begin
j:=i mod 4;
for k:=0 to (i div 4)-1 do begin
int1:=strtoint(strSource[k*4+1]);
int2:=strtoint(strSource[k*4+2]);
int3:=strtoint(strSource[k*4+3]);
int4:=strtoint(strSource[k*4+4]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;

int1:=0;int2:=0;int3:=0;int4:=0;
x:=k*4+1;
if (x)<=i then
int1:=strtoint(strSource[x]);
if (x+1)<=i then
int2:=strtoint(strSource[x+1]);
if (x+2)<=i then
int3:=strtoint(strSource[x+2]);
if (x+3)<=i then
int4:=strtoint(strSource[x+3]);
strDes:=strDes+inttostr(int1+int3)+inttostr(int2+int4);
end;
memo2.Lines.Add(strDes);
end;

end.
walkmangood 2003-09-12
  • 打赏
  • 举报
回复
先定义成一个数组,然后分解字符串,取出1、3位相加,然后在做一次相加
chl_ccssddnn 2003-09-11
  • 打赏
  • 举报
回复
我不会,关注!
同时疑问:硬盘的id是随盘而变的,难道你要在安装时让它自动产生注册码,你的保护软件如何实现呢?

5,379

社区成员

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

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