(Gast)
n/a Beiträge
|
Re: cäsar 1,2,3
6. Mai 2009, 22:21
Falls du es mal brauchst...
Delphi-Quellcode:
function Caesar( const Buffer: String; const Digits: Byte; const Right: Boolean = True;
const _MinVal: Byte = 32; const _MaxVal: Byte = 132 ): String;
var
i, x: Integer;
function InRange(const Value, _Start, _End: Cardinal): Cardinal;
begin
if Value in [_Start.._End] then
Result := Value
else
if Value < _Start then
Result := InRange( _End - _Start + Value+1, _Start, _End )
else
if Value > _End then
Result := InRange( _Start + Value - _End-1, _Start, _End );
end;
begin
if Right then
x := 1
else
x := -1;
SetLength( Result, Length(Buffer) );
for i := 1 to Length(Buffer) do
Result[i] := Chr( Byte( InRange( Ord( Buffer[i] ) + Digits*X, _MinVal, _MaxVal ) ) );
end;
MfG
|
|
Zitat
|