EnctyptClientData.pas 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. unit EnctyptClientData;
  2. interface
  3. uses SysUtils;
  4. type
  5. TScEnryptClient = class
  6. public
  7. function EncryptData(const AIP: string; AUser, AAction: Integer): string;
  8. function DeEncryptData(const Value: string): string;
  9. end;
  10. implementation
  11. uses Math;
  12. { TScEnryptClient }
  13. function TScEnryptClient.DeEncryptData(const Value: string): string;
  14. begin
  15. Result := Copy(Value, 4, Length(Value) - 5);
  16. end;
  17. function TScEnryptClient.EncryptData(const AIP: string; AUser,
  18. AAction: Integer): string;
  19. var
  20. I, iLen: Integer;
  21. rav, slen: string;
  22. begin
  23. Randomize;
  24. SetLength(Result , 27);
  25. rav := IntToStr(Random(10));
  26. Result[1] := rav[1];
  27. rav := IntToStr(Length(AIP));
  28. if Length(rav) = 1 then
  29. begin
  30. Result[2] := '0';
  31. Result[3] := rav[1];
  32. end
  33. else
  34. begin
  35. Result[2] := rav[1];
  36. Result[3] := rav[2];
  37. end;
  38. rav := IntToStr(Random(10));
  39. Result[4] := rav[1];
  40. for I := 1 to Length(AIP) do
  41. begin
  42. Result[I + 4] := AIP[I];
  43. end;
  44. if Length(AIP) < 21 then
  45. begin
  46. iLen := Length(AIP);
  47. while 16 - iLen > 0 do
  48. begin
  49. rav := IntToStr(Random(10));
  50. Result[iLen + 5] := rav[1];
  51. Inc(iLen);
  52. end;
  53. end;
  54. rav := IntToStr(AUser);
  55. slen := IntToStr(Length(rav));
  56. if Length(rav) = 1 then
  57. begin
  58. Result[21] := '0';
  59. Result[22] := rav[1];
  60. Result[26] := '0';
  61. Result[27] := slen[1];
  62. end
  63. else
  64. begin
  65. Result[21] := rav[1];
  66. Result[22] := rav[2];
  67. Result[26] := slen[1];
  68. Result[27] := slen[2];
  69. end;
  70. { Result[21] := rav[1];
  71. rav := IntToStr(Random(10));
  72. Result[22] := rav[1]; }
  73. rav := IntToStr(AAction);
  74. Result[23] := rav[1];
  75. rav := IntToStr(Random(10));
  76. Result[24] := rav[1];
  77. rav := IntToStr(Random(10));
  78. Result[25] := rav[1];
  79. end;
  80. end.