Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  97

•  TDictionary Custom Sort  3 294

•  Fast Watermark Sources  3 044

•  3D Designer  4 799

•  Sik Screen Capture  3 294

•  Patch Maker  3 514

•  Айболит (remote control)  3 612

•  ListBox Drag & Drop  2 970

•  Доска для игры Реверси  81 423

•  Графические эффекты  3 899

•  Рисование по маске  3 210

•  Перетаскивание изображений  2 594

•  Canvas Drawing  2 713

•  Рисование Луны  2 540

•  Поворот изображения  2 147

•  Рисование стержней  2 151

•  Paint on Shape  1 557

•  Генератор кроссвордов  2 214

•  Головоломка Paletto  1 755

•  Теорема Монжа об окружностях  2 194

•  Пазл Numbrix  1 676

•  Заборы и коммивояжеры  2 046

•  Игра HIP  1 271

•  Игра Go (Го)  1 219

•  Симулятор лифта  1 463

•  Программа укладки плитки  1 205

•  Генератор лабиринта  1 535

•  Проверка числового ввода  1 341

•  HEX View  1 481

•  Физический маятник  1 348

 
скрыть


Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Процедуры кодирования и декодирования Base64




function EncodeBase64(const inStr: string): string;

  function Encode_Byte(b: Byte): char;
  const
    Base64Code: string[64] =
      'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  begin
    Result := Base64Code[(b and $3F)+1];
  end;

var
  i: Integer;
begin
  i := 1;
  Result := '';
  while i < =Length(InStr) do
  begin
    Result := Result + Encode_Byte(Byte(inStr[i]) shr 2);
    Result := Result + Encode_Byte((Byte(inStr[i]) shl 4) or (Byte(inStr[i+1]) shr 4));
    if i+1 < =Length(inStr) then
      Result := Result + Encode_Byte((Byte(inStr[i+1]) shl 2) or (Byte(inStr[i+2]) shr 6))
    else
      Result := Result + '=';
    if i+2 < =Length(inStr) then
      Result := Result + Encode_Byte(Byte(inStr[i+2]))
    else
      Result := Result + '=';
    Inc(i, 3);
  end;
end;

// Base64 decoding
function DecodeBase64(const CinLine: string): string;
const
  RESULT_ERROR = -2;
var
  inLineIndex: Integer;
  c: Char;
  x: SmallInt;
  c4: Word;
  StoredC4: array[0..3] of SmallInt;
  InLineLength: Integer;
begin
  Result := '';
  inLineIndex := 1;
  c4 := 0;
  InLineLength := Length(CinLine);

  while inLineIndex < =InLineLength do
  begin
    while (inLineIndex < =InLineLength) and (c4 < 4) do
    begin
      c := CinLine[inLineIndex];
      case c of
        '+'     : x := 62;
        '/'     : x := 63;
        '0'..'9': x := Ord(c) - (Ord('0')-52);
        '='     : x := -1;
        'A'..'Z': x := Ord(c) - Ord('A');
        'a'..'z': x := Ord(c) - (Ord('a')-26);
      else
        x := RESULT_ERROR;
      end;
      if x < > RESULT_ERROR then
      begin
        StoredC4[c4] := x;
        Inc(c4);
      end;
      Inc(inLineIndex);
    end;

    if c4 = 4 then
    begin
      c4 := 0;
      Result := Result + Char((StoredC4[0] shl 2) or (StoredC4[1] shr 4));
      if StoredC4[2] = -1 then Exit;
      Result := Result + Char((StoredC4[1] shl 4) or (StoredC4[2] shr 2));
      if StoredC4[3] = -1 then Exit;
      Result := Result + Char((StoredC4[2] shl 6) or (StoredC4[3]));
    end;
  end;
end;





Похожие по теме исходники

Base64




Copyright © 2004-2024 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте