mEncryptPWD.pas 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. unit mEncryptPWD;
  2. interface
  3. uses
  4. Windows, SysUtils;
  5. function GetEncryptPass1: LongInt;
  6. function GetEncryptPass2: LongInt;
  7. const
  8. ScEncryptKey: array [0..16] of Byte =
  9. ($00, $00, $00, $0D, $CF, $CB, $CD, $CF,
  10. $8C, $8B, $BC, $90, $8D, $8B, $92, $9E,
  11. $AC);
  12. ScAuthorizeKey: array [0..16] of Byte =
  13. ($00, $00, $00, $0D, $8C, $8B, $BC, $90,
  14. $8D, $8B, $92, $9E, $8F, $AC, $9E, $8C,
  15. $B7);
  16. implementation
  17. const
  18. // Demo
  19. //Ps1: array [0..8] of Byte = ($00, $00, $00, $05, $CE, $C8, $CA, $CB, $CE);
  20. //Ps2: array [0..7] of Byte = ($00, $00, $00, $04, $CC, $CD, $C6, $C9);
  21. Ps1: array [0..8] of Byte = ($00, $00, $00, $05, $CD, $C6, $CB, $CA, $CD);
  22. Ps2: array [0..8] of Byte = ($00, $00, $00, $05, $CF, $CA, $CE, $C8, $CE);
  23. // EncryptÃÜÂë
  24. function ExtractPwd(AArray: array of Byte; ALength: Integer): LongInt;
  25. var
  26. OrgLength, I, iTemp: Integer;
  27. TestBuf: array [0..1023] of Char;
  28. TargetBuf: array [0..1027] of Char;
  29. strHexLength: string[8];
  30. strTemp: string;
  31. begin
  32. ZeroMemory(@TestBuf, 1024);
  33. ZeroMemory(@TargetBuf, 1028);
  34. CopyMemory(@TargetBuf, @AArray, ALength*SizeOf(Char));
  35. strHexLength := '';
  36. for I := 0 to 3 do
  37. begin
  38. strHexLength := strHexLength + IntToHex(Byte(TargetBuf[I]), 2);
  39. end;
  40. OrgLength := StrToInt('$' + strHexLength);
  41. for I := 0 to OrgLength - 1 do
  42. begin
  43. if not Odd(I) then
  44. begin
  45. if (I + 1 < OrgLength) then
  46. TestBuf[I] := TargetBuf[I + 1 + 4]
  47. else
  48. TestBuf[I] := TargetBuf[I + 4];
  49. end
  50. else
  51. TestBuf[I] := TargetBuf[I - 1 + 4];
  52. end;
  53. for I := 0 to OrgLength - 1 do
  54. begin
  55. TargetBuf[I] := Char($FF - Byte(TestBuf[I]));
  56. end;
  57. for I := 0 to OrgLength - 1 do
  58. begin
  59. TestBuf[I] := TargetBuf[OrgLength - I - 1];
  60. end;
  61. SetString(strTemp, PChar(@TestBuf[0]), ALength);
  62. Result := StrToInt(strTemp);
  63. end;
  64. function GetEncryptPass1: LongInt;
  65. begin
  66. Result := ExtractPwd(Ps1, Length(Ps1));
  67. end;
  68. function GetEncryptPass2: LongInt;
  69. begin
  70. Result := ExtractPwd(Ps2, Length(Ps2));
  71. end;
  72. end.