10/06/06 21:31:21
BASE32 だから、検索すれば仕様書があるはず。仕様書から作ったほうが早いよ。私はCで作った。
function EncodeB32(s: String): String;
const
B32Char: array[0..31] of Char =
('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
'G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V');
var
i: Integer;
len: Integer;
begin
if s = '' then begin
Result :='';
Exit;
end;
len := (Length(s) * 8 - 1) div 5 + 1;
s := s + StringOfChar(#0, (len * 5 - 1) div 8 + 1 - length(s));
SetLength(Result, len);
for i:=0 to len - 1 do
Result[i + 1] := B32Char[(MakeWord(Byte(s[(i * 5) div 8 + 1]),
Byte(s[(i * 5) div 8 + 2])
) shr ((i * 5) mod 8)
) and 31];
end;