???有谁能把这个函数改成DELPHI的函数吗???--不胜感激(50分)

  • 主题发起人 主题发起人 lxx2008
  • 开始时间 开始时间
L

lxx2008

Unregistered / Unconfirmed
GUEST, unregistred user!
package com.fysoft.v8.v8tools;

import java.util.Random;

public class Password
{

private static String a[] = {
"ke3wms", "jnx9i8", "dpqzl6", "vyg1bh", "7a4c2f", "u5rto0"
};
private static String _flddo[] = {
"wa6j1c", "fblrk7", "mg9q0s", "vu3zth", "po4xy2", "ni5d8e"
};
private static String _fldif[] = {
"mg9qwc", "vu3zth", "a6j10s", "fbk7lr", "5dpoy2", "4xni8e"
};

private Password()
{
}

public static String encrypt(String s)
{
String s1 = "";
s1 = a(s.toLowerCase(), a);
int i = s1.length();
for(int j = 1; j <= 3; j++)
{
s1 = String.valueOf(i % 6) + s1;
i /= 6;
}

Random random = new Random();
for(; s1.length() < 60; s1 = s1 + String.valueOf(random.nextInt(6)));
return _mthif(s1, _flddo);
}

public static String decrypt(String s)
{
String s1 = "";
s1 = a(s, _flddo);
int i = 0;
for(int j = 0; j < 3; j++)
i = i * 6 + Integer.parseInt(String.valueOf(s1.charAt(j)));

s1 = s1.substring(3, 3 + i);
return _mthif(s1, a);
}

private static String a(String s, String as[])
{
String s1 = "";
String s2 = "";
for(int i = 0; i < s.length(); i++)
{
for(int j = 0; j < 6; j++)
{
int k = as[j].indexOf(s.charAt(i));
if(k <= -1)
continue;
s1 = s1 + String.valueOf(j);
s2 = String.valueOf(k) + s2;
break;
}

}

return s1 + s2;
}

private static String _mthif(String s, String as[])
{
String s1 = "";
int i = s.length();
if(i % 2 == 1)
return null;
for(int j = 0; j < i / 2; j++)
{
String s2 = "";
s2 = as[Integer.parseInt(String.valueOf(s.charAt(j)))];
String s3 = String.valueOf(s.charAt(i - j - 1));
s1 = s1 + s2.charAt(Integer.parseInt(s3));
}

return s1;
}

}
 
然道没有人知道,!!吗?我
 
不要光要代码,
你什么地方在转换的时候有问题?说出来看看
 
哦,我是一个初学者,我不知到比如把encrypt(z)是多少
 
const
a: array[0..5] of string = ('ke3wms', 'jnx9i8', 'dpqzl6', 'vyg1bh', '7a4c2f', 'u5rto0');
_flddo: array[0..5] of string = ('wa6j1c', 'fblrk7', 'mg9q0s', 'vu3zth', 'po4xy2', 'ni5d8e');
_fldif: array[0..5] of string = ('mg9qwc', 'vu3zth', 'a6j10s', 'fbk7lr', '5dpoy2', '4xni8e');

function ValueOf(I: Integer): string;
begin
SetLength(Result, 4);
CopyMemory(POinter(Result), Pointer(I), 4);
end;

function Build(S: string; aList: array of string): string;
var
s1, s2: string;
I, J, K: Integer;
begin
for I := 0 to Length(S) - 1 do
begin
for J := 0 to 5 do
begin
K := Pos(s, aList[J]);
if K <= -1 then
Continue;

s1 := s1 + ValueOf(I);
s2 := ValueOf(K) + s2;
break;
end;
end;

Result := s1 + s2;
end;

function Encrypt(S: string): string;
var
s1: string;
I, J: Integer;
begin
s1 := Build(LowerCase(S), a);
I := Length(S1);
for J := 1 to 3 do
begin
s1 := ValueOf(I mod 6) + s1;
i := i div 6;
end;

Randomize;
// for(; s1.length() < 60; s1 = s1 + String.valueOf(random.nextInt(6)));
while Length(s1) < 60 do
s1 := s1 + ValueOf(RandomRange(0, 6));

Result := _mthif(s1, a); //这个你自己改吧
end;
 

Similar threads

I
回复
0
查看
729
import
I
I
回复
0
查看
658
import
I
I
回复
0
查看
843
import
I
后退
顶部