



Função de decodifica string criptografadas na base 64.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | function Decode64(S: string): string; const Codes64 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/'; var i: Integer; a: Integer; x: Integer; b: Integer; begin Result := ''; a := 0; b := 0; for i := 1 to Length(s) do begin x := Pos(s[i], codes64) - 1; if x >= 0 then begin b := b * 64 + x; a := a + 6; if a >= 8 then begin a := a - 8; x := b shr a; b := b mod (1 shl a); x := x mod 256; Result := Result + chr(x); end; end else Exit; end; end; |
Exemplo de uso:
1 2 3 4 5 6 7 | procedure TForm1.Button1Click(Sender: TObject); var s : String; begin s := Decode64('KsXlTo14PMnmQ6a'); // Show Delphi codificado 64 ShowMessage(s); end; |