cs_davidc
Messages postés4Date d'inscriptionmardi 29 avril 2003StatutMembreDernière intervention25 janvier 2009
-
20 janv. 2009 à 23:36
cs_davidc
Messages postés4Date d'inscriptionmardi 29 avril 2003StatutMembreDernière intervention25 janvier 2009
-
25 janv. 2009 à 00:15
Bonsoir, je désirerais avoir une explication assez détaillée pour la portion de code en rouge Merci:
function TForm1.DecodeMSKey(const HexSrc: array of byte): string;
const StartOffset: integer $34; // Offset 34 Array[52] EndOffset: integer $34 + 15; // Offset 34 + 15(Bytes) Array[64]
Digits: array[0..23] of char =
('B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 'T',
'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9');
DecodedLen: integer = 29; // Length of Decoded Product Key
EncodedLen: integer = 15;
// Length of Encoded Product Key in Bytes (An total of 30 in chars)
var
HexDigitalPID: array of cardinal;
Des: array[0..30] of char; // Length of Decoded Product Key + 1
I: integer;
N: integer;
HN: cardinal;
Value: cardinal;
begin
Result := '';
SetLength(HexDigitalPID, DecodedLen);
for I := StartOffset to EndOffset do
HexDigitalPID[I - StartOffSet] := HexSrc[I];
// SetLength(Des, DecodedLen + 1);
for I := DecodedLen - 1 downto 0 do
if (((I + 1) mod 6) = 0) then
Des[I] := '-'
else
begin
HN := 0;
for N := EncodedLen - 1 downto 0 do
begin
Value := (HN shl 8) or HexDigitalPID[N];
HexDigitalPID[N] := Value div 24;
HN := Value mod 24;
end;
Des[I] := Digits[HN];
end;
Des[DecodedLen] := Chr(0);
// For I := 0 To Length(Des) Do
// begin
// Result := Result + Des[I];
// end;
Result := StrPas(Des);
end;
cs_davidc
Messages postés4Date d'inscriptionmardi 29 avril 2003StatutMembreDernière intervention25 janvier 2009 25 janv. 2009 à 00:15
Bonsoir, j'ai bien regardé votre explication et je ne comprends pas tres biens comment se calcule le Value := (HN shl 8) or HexDigitalPID[N]; en effet comment calculerait-on avec une HexDigitalPID = 01 CC 06 C7 A0 5D 84 2A 87 C1 EB CC 75 04 80, valeurs hexadécimale ? Merci