"Боевой режим "
Фон локальная AUTOMATIC1111 Stable Diffusion Web UI + несколько онлайн сервисов в отдельных окнах
Модератор: Модераторы
Decode UUE, Base64 and yEncoded messages.
Uses
... ,DECFmt, DECUtil;
//...
var
S: string;
UUE: Binary;
//..
with TFormat_UU.Create do
begin
S := 'Delphi-Encryption-Compendium Вроде все просто! ';
UUE := TFormat_UU.Encode( S[1] ,Length(S));
ShowMessage('uue Encode :'+ uue);
S:= TFormat_UU.Decode(uue);
ShowMessage('uue Decode :'S);
Free;
end;
Alexander писал(а):Раскодировка может быть здесь ?
Procedure.s UUDecode(sInBuf.s)
sOutBuf.s = ""
For lLoop = 1 To Len(sInBuf) Step 4
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop, 1)) - 32) * 4 + (Asc(Mid(sInBuf, lLoop + 1, 1)) - 32) / 16)
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop + 1, 1)) % 16) * 16 + (Asc(Mid(sInBuf, lLoop + 2, 1)) - 32) / 4)
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop + 2, 1)) % 4) * 64 + Asc(Mid(sInBuf, lLoop + 3, 1)) - 32)
Next lLoop
ProcedureReturn sOutBuf
EndProcedure
Procedure.s UUEncode(sInBuf.s)
sOutBuf.s = ""
For lLoop = 1 To Len(sInBuf) Step 3
sOutBuf = sOutBuf + Chr(Asc(Mid(sInBuf, lLoop, 1)) / 4 + 32)
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop, 1)) % 4) * 16 + Asc(Mid(sInBuf, lLoop + 1, 1)) / 16 + 32)
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop + 1, 1)) % 16) * 4 + Asc(Mid(sInBuf, lLoop + 2, 1)) / 64 + 32)
sOutBuf = sOutBuf + Chr(Asc(Mid(sInBuf, lLoop + 2, 1)) % 64 + 32)
Next lLoop
ProcedureReturn sOutBuf
EndProcedure
sText.s = uuEncode("1234567890abcdefghijklmnopqrstuvwxyz")
Debug "Encoded=" + sText
sText = uuDecode(sText)
Debug "Decoded=" + sText
Alex2013 писал(а):тут продвинутая работа с ini -фалами
Alexander писал(а):однако есть идея зашить этот функционал прямо в код
RRYTY писал(а):Давным-давно пользую пакет dcpcrypt-2.0.4.1
В составе есть модуль работы с Base64.
function UUDecode(ByVal sInBuf as String) as String
Dim sOutBuf as String = ""
Dim lLoop as Unsigned Long
For lLoop = 1 To Len(sInBuf) Step 4
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop, 1)) - 32) * 4 + (Asc(Mid(sInBuf, lLoop + 1, 1)) - 32) / 16)
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop + 1, 1)) Mod 16) * 16 + (Asc(Mid(sInBuf, lLoop + 2, 1)) - 32) / 4)
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop + 2, 1)) Mod 4) * 64 + Asc(Mid(sInBuf, lLoop + 3, 1)) - 32)
Next lLoop
return sOutBuf
End function
function UUEncode(ByVal sInBuf as String) as String
Dim sOutBuf as String = ""
Dim lLoop as Unsigned Long
For lLoop = 1 To Len(sInBuf) Step 3
sOutBuf = sOutBuf + Chr(Asc(Mid(sInBuf, lLoop, 1)) / 4 + 32)
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop, 1)) Mod 4) * 16 + Asc(Mid(sInBuf, lLoop + 1, 1)) / 16 + 32)
sOutBuf = sOutBuf + Chr((Asc(Mid(sInBuf, lLoop + 1, 1)) Mod 16) * 4 + Asc(Mid(sInBuf, lLoop + 2, 1)) / 64 + 32)
sOutBuf = sOutBuf + Chr(Asc(Mid(sInBuf, lLoop + 2, 1)) Mod 64 + 32)
Next lLoop
return sOutBuf
End function
Dim sText as String
sText = UUEncode("1234567890abcdefghijklmnopqrstuvwxyz")
Print( "Encoded=" + sText )
sText = UUDecode(sText)
Print( "Decoded=" + sText )
./uu
Encoded=,3)S-#5V.TAY,&&B9V2E:F>H:7JK;'VN<W"Q<G.T=7:W>(FZ
Decoded=12s45v;Hy0b�gd�jh�iz�l~�sp�rt�uv�x��
RRYTY писал(а):Не только написать "Hello, world!" в файл, но еще и прочитать это из файла! }:-)
program uued;
{$MODE OBJFPC}
{$H+}
{$SMARTLINK ON}
{$RANGECHECKS ON}
function UUDecode(sInBuf : string) : string;
var
lLoop : Int64 = 1;
begin
result := '';
while lLoop <= Length(sInBuf) do begin
result := result + Chr((Ord(sInBuf[lLoop]) - 32) * 4 + (Ord(sInBuf[lLoop+1]) - 32) div 16);
result := result + Chr((Ord(sInBuf[lLoop+1]) mod 16) * 16 + (Ord(sInBuf[lLoop+2]) - 32) div 4);
result := result + Chr((Ord(sInBuf[lLoop+2]) mod 4) * 64 + Ord(sInBuf[lLoop+3]) - 32);
Inc(lLoop, 4);
end;
End;
function UUEncode(sInBuf : string) : string;
var
lLoop : Int64 = 1;
begin
result := '';
while lLoop <= Length(sInBuf) do begin
result := result + Chr(Ord(sInBuf[lLoop]) div 4 + 32);
result := result + Chr((Ord(sInBuf[lLoop]) mod 4) * 16 + Ord(sInBuf[lLoop+1]) div 16 + 32);
result := result + Chr((Ord(sInBuf[lLoop+1]) mod 16) * 4 + Ord(sInBuf[lLoop+2]) div 64 + 32);
result := result + Chr(Ord(sInBuf[lLoop+2]) mod 64 + 32);
Inc(lLoop, 3);
end;
End;
var
sText : string;
begin
sText := UUEncode('1234567890abcdefghijklmnopqrstuvwxyz');
WriteLn('Encoded=' + sText);
sText := UUDecode(sText);
WriteLn('Decoded=' + sText);
end.
result := result + Chr((Ord(sInBuf[lLoop]) - 32) shr 2 + (Ord(sInBuf[lLoop+1]) - 32) shl 4);
result := result + Chr((Ord(sInBuf[lLoop+1]) shl 4 ) shr 4 + (Ord(sInBuf[lLoop+2]) - 32) shl 2 );
result := result + Chr((Ord(sInBuf[lLoop+2]) shl 2) shr 8 + Ord(sInBuf[lLoop+3]) - 32);
program uued;
{$MODE OBJFPC}
{$H+}
{$SMARTLINK ON}
{$RANGECHECKS ON}
function UUDecode(s : string) : string;
var
f : Int64 = 1;
begin
result := '';
while f <= Length(s) do begin
result := result + Chr((Ord(s[f]) - 32) shl 2 + (Ord(s[f+1]) - 32) shr 4);
result := result + Chr((Ord(s[f+1]) and 15) shl 4 + (Ord(s[f+2]) - 32) shr 2);
result := result + Chr((Ord(s[f+2]) and 3) shl 6 + Ord(s[f+3]) - 32);
Inc(f, 4);
end;
End;
function UUEncode(s : string) : string;
var
f : Int64 = 1;
begin
result := '';
while f <= Length(s) do begin
result := result + Chr(Ord(s[f]) shr 2 + 32);
result := result + Chr((Ord(s[f]) and 3) shl 4 + Ord(s[f+1]) shr 4 + 32);
result := result + Chr((Ord(s[f+1]) and 15) shl 2 + Ord(s[f+2]) shr 6 + 32);
result := result + Chr(Ord(s[f+2]) and 63 + 32);
Inc(f, 3);
end;
End;
var
sText : string;
begin
sText := UUEncode('1234567890abcdefghijklmnopqrstuvwxyz');
WriteLn('Encoded=' + sText);
sText := UUDecode(sText);
WriteLn('Decoded=' + sText);
end.
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1