Delphi-Help

  • Increase font size
  • Default font size
  • Decrease font size
Главная Статьи Шифрование 64-битное кодирование 2

64-битное кодирование 2

Оцените материал
(1 Голосовать)

64-битное кодирование 2

const
 
  Base64Table =
    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
 
function Base64Decode(cStr: string): string;
var
  ResStr: string;
 
  DecStr: string;
  RecodeLine: array[1..76] of byte;
  f1, f2: word;
  l: integer;
begin
  l := length(cStr);
  ResStr := '';
  for f1 := 1 to l do
    if cStr[f1] = '=' then
      RecodeLine[f1] := 0
    else
      RecodeLine[f1] := pos(cStr[f1], Base64Table) - 1;
  f1 := 1;
  while f1 < length(cStr) do
  begin
    DecStr := chr(byte(RecodeLine[f1] shl 2) + RecodeLine[f1 + 1] shr 4) +
      chr(byte(RecodeLine[f1 + 1] shl 4) + RecodeLine[f1 + 2] shr 2) +
      chr(byte(RecodeLine[f1 + 2] shl 6) + RecodeLine[f1 + 3]);
    ResStr := ResStr + DecStr;
    inc(f1, 4);
  end;
  Base64Decode := ResStr;
end;
Прочитано 10845 раз
Другие материалы в этой категории: « 64-битное кодирование Пример шифрования текста »

Авторизация



Счетчики