日期:2014-05-19  浏览次数:20671 次

谁能帮我翻译这段delphi程序为java程序
function GetPassWord(PassWord: String): String;  
  var
  Str,rStr: String;
  Cha: Char;
  I,len: integer;
  function Upchar(key: Char): Char;
  var
  i,max: integer;
  begin
  Max := Ord('z');
  i := Ord(key)+ 7 ;
  if i > max then i := i- 26;
  Result := Chr(i);
  end;

  function UpcharA(key: Char): Char;
  var
  i,max: integer;
  begin
  Max := Ord('Z');
  i := Ord(key)+ 5 ;
  if i > max then i := i- 26;
  Result := Chr(i);
  end;

  function UpcharN(key: Char): Char;
  var
  i,max: integer;
  begin
  Max := Ord('9');
  i := Ord(key)+ 3 ;
  if i > max then i := i- 10;
  Result := Chr(i);
  end;

  function Encrypt(const S: String; Key: Word): String;
  var
  I: Integer;
  begin
  Result := S;
  for I := 1 to Length(S) do
  begin
  Result[I] := char(byte(S[I]) xor Key);
  key := (byte(S[I])+i);
  end;
  end;
  function myStrToHex(StrSou: string): string;
  var
  i: integer;
  S,Temp,ResStr: string;
  begin
  S := StrSou;
  for i := 1 to length(S) do
  begin
  Temp := Format('%x', [ord(S[i])]);
  Temp := copy('00',1, 2-length(Temp)) + Temp;
  ResStr := ResStr + Temp;
  end;
  Result := ResStr;
  end;
  begin
  Str := TRim(PassWord);
  len := Length(Str);
  for i := 1 to len do
  begin
  Cha := Str[i];
  if Cha in ['a'..'z'] then
  Cha :=upchar(Cha)
  else if Cha in ['A'..'Z'] then
  Cha :=upcharA(Cha)
  else if Cha in ['0'..'9'] then
  Cha :=upcharN(Cha) ;
  rStr := rStr + Cha;
  end;
  Result := EnCrypt(rStr,123);
  Result := myStrToHex(Result);
  end;

------解决方案--------------------

坐等高手