function jm(S: string): string;
var i: Byte;
begin
for i := 1 to Length(S) do
S[i] := Char(ord(S[i]) xor (i + 3));
jm := S;
end;
function CryptStr(const S:String; sType: DWord):String;
var
i: Integer;
FKey: Integer;
begin
result:='';
case sType of
0: SetPass;
begin
Randomize;
FKey := Random($FF);
for i:=1 to Length(s) do
Result := Result+Chr( Ord(s[i]) xor i xor FKey);
Result := Result + Char(FKey);
end;
1: GetPass
Begin
FKey := Ord(S[Length(s)]);
for i:=1 to Length(s) - 1 do
Result := Result+Chr( Ord(s[i]) xor i xor FKey);
end;
end;
Public Function 数字加密(a As Long) As Long
Dim E As Integer
Dim C As Integer
Dim P As Integer
E = 1021
C = 1
P = 257
L1:
If (E = 0) Then
数字加密 = C
Else
L2:
If (E Mod 2 = 0) Then
E = E \ 2
a = (a * a) Mod P
GoTo L2
Else
E = E - 1
C = (C * a) Mod P
GoTo L1
End If
End If
End Function
Public Function 数字解密(a As Long) As Long
Dim D As Integer
Dim C As Integer
Dim P As Integer
D = 853
C = 1
P = 257
L1:
If (D = 0) Then
数字解密 = C
Else
L2:
If (D Mod 2 = 0) Then
D = D \ 2
a = (a * a) Mod P
GoTo L2
Else
D = D - 1
C = (C * a) Mod P
GoTo L1
End If
End If
End Function
Rem 字符串加密成密匙算法
Public Function Encoder_Key(Str As String) As String
Rem hxf --> 185,34,243
Dim I As Integer
Dim Ch As String
Dim Code As String
For I = 1 To Len(Str)
Ch = Mid(Str, I, 1)
If (I <> 1) Then Encoder_Key = Encoder_Key & ","
Encoder_Key = Encoder_Key & 数字加密(Asc(Ch))
Next I
End Function
Rem 密匙还原成字符串算法
Public Function Decoder_Key(Str As String) As String
Dim I As Integer
Dim Ch As String
Dim Str1 As String
Str = Str & ","
For I = 1 To Len(Str)
Ch = Mid(Str, I, 1)
If (Ch <> ",") Then
Str1 = Str1 & Ch
Else
Decoder_Key = Decoder_Key & Chr(数字解密(CLng(Str1)))
Str1 = ""
End If
Next I
End Function