java代码如下:
public static String DecodePasswd(String varCode)
{
String des = new String();
String strKey = new String();
if(varCode == null || varCode.length() == 0)
return "";
strKey = "zxcvbnm,./asdfghjkl;'qwertyuiop[]\\1234567890-=` ZXCVBNM<>?:LKJHGFDSAQWERTYUIOP{}|+_)(*&^%$#@!~";
if(varCode.length() % 2 == 1)
varCode = String.valueOf(String.valueOf(varCode)).concat("?");
des = "";
int n;
for(n = 0; n <= varCode.length() / 2 - 1; n++)
{
char b = varCode.charAt(n * 2);
int a = strKey.indexOf(varCode.charAt(n * 2 + 1));
des = String.valueOf(des) + String.valueOf((char)(b ^ a));
}
n = des.indexOf(1);
if(n > 0)
return des.substring(0, n);
else
return des;
}
以上这段代码在翻译成delphi中,我翻译的如下:function TForm1.Translate(varCode: string): string;
var
des,strKey,b: string;
n,a,changdu: integer;
begin
changdu:= length(varcode);
//怎么定义下边这个字符串
//strKey = 'zxcvbnm,./asdfghjkl;'qwertyuiop[]\\1234567890-=` ZXCVBNM<>?:LKJHGFDSAQWERTYUIOP{}|+_)(*&^%$#@!~';
if (varcode='') or (changdu<=0) then
result:=''
else begin
if (changdu mod 2=1) then varcode:= concat(varcode,'?');
for n:=0 to (changdu div 2) -1 do
begin
b:= copy(varcode,1,n*2); //
a:= pos(strkey,copy(varcode,1,n*2+1)); //
//des的值,下面这句应该怎么写?
des:= strtoint(des)+
end;
end;
//下面该怎么写?
result:= des;谢谢!
public static String DecodePasswd(String varCode)
{
String des = new String();
String strKey = new String();
if(varCode == null || varCode.length() == 0)
return "";
strKey = "zxcvbnm,./asdfghjkl;'qwertyuiop[]\\1234567890-=` ZXCVBNM<>?:LKJHGFDSAQWERTYUIOP{}|+_)(*&^%$#@!~";
if(varCode.length() % 2 == 1)
varCode = String.valueOf(String.valueOf(varCode)).concat("?");
des = "";
int n;
for(n = 0; n <= varCode.length() / 2 - 1; n++)
{
char b = varCode.charAt(n * 2);
int a = strKey.indexOf(varCode.charAt(n * 2 + 1));
des = String.valueOf(des) + String.valueOf((char)(b ^ a));
}
n = des.indexOf(1);
if(n > 0)
return des.substring(0, n);
else
return des;
}
以上这段代码在翻译成delphi中,我翻译的如下:function TForm1.Translate(varCode: string): string;
var
des,strKey,b: string;
n,a,changdu: integer;
begin
changdu:= length(varcode);
//怎么定义下边这个字符串
//strKey = 'zxcvbnm,./asdfghjkl;'qwertyuiop[]\\1234567890-=` ZXCVBNM<>?:LKJHGFDSAQWERTYUIOP{}|+_)(*&^%$#@!~';
if (varcode='') or (changdu<=0) then
result:=''
else begin
if (changdu mod 2=1) then varcode:= concat(varcode,'?');
for n:=0 to (changdu div 2) -1 do
begin
b:= copy(varcode,1,n*2); //
a:= pos(strkey,copy(varcode,1,n*2+1)); //
//des的值,下面这句应该怎么写?
des:= strtoint(des)+
end;
end;
//下面该怎么写?
result:= des;谢谢!
解决方案 »
- 急求救!!!!!!!!!
- Windows MediaPlayer的操作(注意:不是delphi自带的那个)
- 初学求助:如何求两个日期之间相隔的天数
- 求有关报表基础知识的电子书籍
- 关于对象库的一个问题new->Dialogs->Dialogs with help..
- FastReport的很难的问题?
- 各位高手请帮帮我这个菜鸟吧
- help help help help!!!!!!!
- 有关网络的问题,暂给60分...
- 解决这个问题,给你100分。(一个关于打印方面的问题)
- 想做一个红绿灯不停闪烁的界面,不知怎么样做才好
- 请问哪里可以下载Delphi帮助中文版的????请告诉具体网址,thanks!
var
des, strKey: string;
n, a, changdu: integer;
b: char;
begin
changdu := length(varcode); strKey =
QuotedStr('zxcvbnm,./asdfghjkl;''qwertyuiop[]\\1234567890-=` ZXCVBNM<>?:LKJHGFDSAQWERTYUIOP{}|+_)(*&^%$#@!~');
if (varcode = '') or (changdu <= 0) then
begin
result := '';
exit;
end; if ((changdu mod 2) = 1) then varCode := varCode + '?'; for n := 0 to (changdu div 2) - 1 do
begin
b := Ord(varcode[n * 2]); //這裹要修改, 從1開始取值
a := Pos(varcode[n * 2 + 1], strKey);
des := Des + intToStr(b * a);
end;
result := des;
end;