超难问题:JAVA和DELPHI高手,JAVA----〉DELPHI 150分奉上 (150分)

  • 主题发起人 主题发起人 china1
  • 开始时间 开始时间
C

china1

Unregistered / Unconfirmed
GUEST, unregistred user!
package password;
import java.io.PrintStream;
public class password
{
public password()
{
}
public static void main(String args[])
{
password test = new password();
System.out.println(test.passwordEncrypt("abcdefgh"));
}
public String passwordEncrypt(String password)
{
String s;
try
{
byte bytes1[] = password.getBytes("ISO-8859-1");
byte bytes2[] = {
9, 10, 13, 13, 10, 13, 9, 10, 13, 10,
10, 13
};
for(int i = 0;
i < bytes1.length &amp;&amp;
i < bytes2.length;
i++)
bytes1 = (byte)(bytes1 ^ bytes2);
String s1 = new String(bytes1, "ISO-8859-1");
return s1;
}
catch(Exception theException)
{
s = null;
}
return s;
}
}
 
function passwordEncrypt(password:string):string;
var
s1:string;
i,j:integer;
bytes2:string
begin
try
bytes1:='ISO-8859-1';
bytes2:=#9#10#13#9#10#13#13#10#13#9#10#13#10#10#13;
j:=length(bytes1);
if j>length(bytes2) then
j:=length(bytes2);
for i:=1 to jdo
bytes1:=bytes xor bytes2;
s1:=bytes1+'ISO-8859-1';//String(bytes1, "ISO-8859-1");这是连接么
result:=s1;
except
s1:='';
end;
result:=s1;
end;
不知道对否
 
s1:=bytes1+'ISO-8859-1';//String(bytes1, "ISO-8859-1");这是连接么
改成s1:= bytes1;就可以了。
String(bytes1, "ISO-8859-1")应该是把bytes1转化为ISO-8859-1的格式。
 
function passwordEncrypt(password:string):string;
var
s:String;
bytes1:String;
bytes2:String;
i:integer;
begin
try
bytes1:=password;
bytes2:=#9#10#13#13#10#13#9#10#13#10#10#13;
i:=1;
while (i<=length(bytes1)) and (i<=Length(bytes2))do
begin
bytes1:= Char(Byte(bytes1) xor Byte(bytes2));
inc(i);
end;
s:=bytes1;
except
on Exceptiondo
s:='';
end;
result:=s;
end;
 
多人接受答案了。
 
后退
顶部