Показать сообщение отдельно
  #4  
Старый 07.12.2021, 18:45
lmikle lmikle вне форума
Модератор
 
Регистрация: 17.04.2008
Сообщения: 7,785
Версия Delphi: 7, XE3, 10.2
Репутация: 49089
По умолчанию

Вообще, добрые люди уже перевели. Стоит только поискать:
Код:
const
  _C2I: array [0..255] of byte = (
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
    36, 255, 255, 255, 37, 38, 255, 255, 255, 255, 39, 40, 255, 41, 42, 43,
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, 255, 255, 255, 255, 255,

    255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
    23, 24, (* uppercase *)
    25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 , 35, 255, 255, 255, 255,
    255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
    23, 24, (* lowercase *)
    25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 35, 255, 255, 255, 255,

    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,

    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255);


procedure base45_decode ( const AInput, AOutput: TStream);
var
  ch, a, b: byte;
  x: word;
begin
  ch: = 0;
  repeat
    AInput. Read (ch, 1);
    a: = _C2I [ch];

    AInput. Read (ch, 1);
    b: = _C2I [ch];

    if (a = 255) or (b = 255) then
      exit;

    x: = a + 45 * b;

    if AInput.Position <AInput.Size then
    begin
      AInput. Read (ch, 1);
      a: = _C2I [ch];

      if a = 255 then
        exit;
      x: = x + (a * 45 * 45);

      ch: = x shr 8;
      AOutput. Write (ch, 1);
    end ;
    ch: = x and $ FF;
    AOutput. Write (ch, 1);
  until AInput.Position = AInput.Size;
end ;

PS. Не проверял.
Ответить с цитированием