summaryrefslogtreecommitdiff
path: root/lowlevelunit.pas
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2015-10-14 12:08:29 +0200
committerErich Eckner <git@eckner.net>2015-10-14 12:08:29 +0200
commit00c6a0daa5506f26659e26ed65043f0c88fb2d39 (patch)
treeaf86bbf94c070c9aaf4a4ad5f066f8f00937269d /lowlevelunit.pas
parentbb11e18abc0b3f403dbe2f9700f778a9460f0522 (diff)
downloadunits-00c6a0daa5506f26659e26ed65043f0c88fb2d39.tar.xz
base64 zu binär eingebaut
Diffstat (limited to 'lowlevelunit.pas')
-rw-r--r--lowlevelunit.pas38
1 files changed, 38 insertions, 0 deletions
diff --git a/lowlevelunit.pas b/lowlevelunit.pas
index 63b8f90..65e266e 100644
--- a/lowlevelunit.pas
+++ b/lowlevelunit.pas
@@ -79,6 +79,11 @@ function tIntPointToStr(p: tIntPoint): string;
procedure fehler(s: string);
function hexDump(p: pointer; cnt: longint): string;
+function base64ToBin(var s: string): boolean;
+
+var
+ base64Chars: array[0..63] of char;
+ base64CharsInvers: array[char] of byte;
implementation
@@ -658,9 +663,42 @@ begin
result:=result+inttohex((pByte(p)+i)^,2);
end;
+function base64ToBin(var s: string): boolean;
+var
+ i,j: longint;
+ t: string;
+ b: byte;
+begin
+ t:='';
+ result:=false;
+ for i:=1 to length(s) do begin
+ b:=base64CharsInvers[s[i]];
+ if b=255 then exit;
+ for j:=5 downto 0 do
+ t:=t+char(ord('0')+byte(odd(b shr j)));
+ end;
+ s:=t;
+ result:=true;
+end;
+
+var b: byte;
+
begin
_cpuLastUsed:=0;
_cpuLastIdle:=0;
cpuUtilization;
+
+ for b:=0 to 25 do begin
+ base64Chars[b]:= char(b+ord('A'));
+ base64Chars[b+26]:=char(b+ord('a'));
+ end;
+ for b:=0 to 9 do
+ base64Chars[52+b]:=char(b+ord('0'));
+ base64Chars[62]:='+';
+ base64Chars[63]:='/';
+ for b:=0 to 255 do
+ base64CharsInvers[char(b)]:=255;
+ for b:=0 to 63 do
+ base64CharsInvers[base64Chars[b]]:=b;
end.