diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-14 17:50:15 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-14 17:50:15 +0000 |
commit | c95efb840d744ec332edfe311b69f1c7ac56560a (patch) | |
tree | 38be8d8b82deaa5b35de0dba5261b442ccd656e8 /plugins/HistoryPlusPlus | |
parent | d30ebf7e3b54d8a5887c0f6c2382987f8ad80420 (diff) |
built-in base64 removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@5689 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HistoryPlusPlus')
-rw-r--r-- | plugins/HistoryPlusPlus/Base64.pas | 140 | ||||
-rw-r--r-- | plugins/HistoryPlusPlus/Checksum.pas | 34 | ||||
-rw-r--r-- | plugins/HistoryPlusPlus/historypp.dpr | 1 | ||||
-rw-r--r-- | plugins/HistoryPlusPlus/historypp.dproj | 1 |
4 files changed, 11 insertions, 165 deletions
diff --git a/plugins/HistoryPlusPlus/Base64.pas b/plugins/HistoryPlusPlus/Base64.pas deleted file mode 100644 index 37e37a5553..0000000000 --- a/plugins/HistoryPlusPlus/Base64.pas +++ /dev/null @@ -1,140 +0,0 @@ -{******************************************************************************}
-{* DCPcrypt v2.0 written by David Barton (davebarton@bigfoot.com) *************}
-{******************************************************************************}
-{* A Base64 encoding/decoding unit ********************************************}
-{******************************************************************************}
-{* Copyright (c) 1999-2000 David Barton *}
-{* Permission is hereby granted, free of charge, to any person obtaining a *}
-{* copy of this software and associated documentation files (the "Software"), *}
-{* to deal in the Software without restriction, including without limitation *}
-{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *}
-{* and/or sell copies of the Software, and to permit persons to whom the *}
-{* Software is furnished to do so, subject to the following conditions: *}
-{* *}
-{* The above copyright notice and this permission notice shall be included in *}
-{* all copies or substantial portions of the Software. *}
-{* *}
-{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *}
-{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *}
-{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *}
-{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *}
-{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *}
-{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *}
-{* DEALINGS IN THE SOFTWARE. *}
-{******************************************************************************}
-unit Base64;
-
-interface
-
-function Base64EncodeStr(const Value: AnsiString): AnsiString;
- { Encode a AnsiString into Base64 format }
-function Base64DecodeStr(const Value: AnsiString): AnsiString;
- { Decode a Base64 format AnsiString }
-function Base64Encode(pInput: pointer; pOutput: pointer; Size: longint): longint;
- { Encode a lump of raw data (output is (4/3) times bigger than input) }
-function Base64Decode(pInput: pointer; pOutput: pointer; Size: longint): longint;
- { Decode a lump of raw data }
-
-
-{******************************************************************************}
-{******************************************************************************}
-implementation
-
-type {from Sysutils}
- PByteArray = ^TByteArray;
- TByteArray = array[0..32767] of Byte;
-
-const
- B64: array[0..63] of byte= (65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
- 81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,
- 109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,
- 54,55,56,57,43,47);
-
-function Base64Encode(pInput: pointer; pOutput: pointer; Size: longint): longint;
-var
- i, iptr, optr: integer;
- Input, Output: PByteArray;
-begin
- Input:= PByteArray(pInput); Output:= PByteArray(pOutput);
- iptr:= 0; optr:= 0;
- for i:= 1 to (Size div 3) do
- begin
- Output^[optr+0]:= B64[Input^[iptr] shr 2];
- Output^[optr+1]:= B64[((Input^[iptr] and 3) shl 4) + (Input^[iptr+1] shr 4)];
- Output^[optr+2]:= B64[((Input^[iptr+1] and 15) shl 2) + (Input^[iptr+2] shr 6)];
- Output^[optr+3]:= B64[Input^[iptr+2] and 63];
- Inc(optr,4); Inc(iptr,3);
- end;
- case (Size mod 3) of
- 1: begin
- Output^[optr+0]:= B64[Input^[iptr] shr 2];
- Output^[optr+1]:= B64[(Input^[iptr] and 3) shl 4];
- Output^[optr+2]:= byte('=');
- Output^[optr+3]:= byte('=');
- end;
- 2: begin
- Output^[optr+0]:= B64[Input^[iptr] shr 2];
- Output^[optr+1]:= B64[((Input^[iptr] and 3) shl 4) + (Input^[iptr+1] shr 4)];
- Output^[optr+2]:= B64[(Input^[iptr+1] and 15) shl 2];
- Output^[optr+3]:= byte('=');
- end;
- end;
- Result:= ((Size+2) div 3) * 4;
-end;
-
-function Base64EncodeStr(const Value: AnsiString): AnsiString;
-begin
- SetLength(Result,((Length(Value)+2) div 3) * 4);
- Base64Encode(@Value[1],@Result[1],Length(Value));
-end;
-
-function Base64Decode(pInput: pointer; pOutput: pointer; Size: longint): longint;
-var
- i, j, iptr, optr: integer;
- Temp: array[0..3] of byte;
- Input, Output: PByteArray;
-begin
- Input:= PByteArray(pInput); Output:= PByteArray(pOutput);
- iptr:= 0; optr:= 0;
- Result:= 0;
- for i:= 1 to (Size div 4) do
- begin
- for j:= 0 to 3 do
- begin
- case Input^[iptr] of
- 65..90 : Temp[j]:= Input^[iptr] - Ord('A');
- 97..122: Temp[j]:= Input^[iptr] - Ord('a') + 26;
- 48..57 : Temp[j]:= Input^[iptr] - Ord('0') + 52;
- 43 : Temp[j]:= 62;
- 47 : Temp[j]:= 63;
- 61 : Temp[j]:= $FF;
- end;
- Inc(iptr);
- end;
- Output^[optr]:= (Temp[0] shl 2) or (Temp[1] shr 4);
- Result:= optr+1;
- if (Temp[2]<> $FF) and (Temp[3]= $FF) then
- begin
- Output^[optr+1]:= (Temp[1] shl 4) or (Temp[2] shr 2);
- Result:= optr+2;
- Inc(optr)
- end
- else if (Temp[2]<> $FF) then
- begin
- Output^[optr+1]:= (Temp[1] shl 4) or (Temp[2] shr 2);
- Output^[optr+2]:= (Temp[2] shl 6) or Temp[3];
- Result:= optr+3;
- Inc(optr,2);
- end;
- Inc(optr);
- end;
-end;
-
-function Base64DecodeStr(const Value: AnsiString): AnsiString;
-begin
- SetLength(Result,(Length(Value) div 4) * 3);
- SetLength(Result,Base64Decode(@Value[1],@Result[1],Length(Value)));
-end;
-
-
-end.
diff --git a/plugins/HistoryPlusPlus/Checksum.pas b/plugins/HistoryPlusPlus/Checksum.pas index 47ab3245c9..777d15af4a 100644 --- a/plugins/HistoryPlusPlus/Checksum.pas +++ b/plugins/HistoryPlusPlus/Checksum.pas @@ -60,7 +60,7 @@ var implementation
uses
- SysUtils, Base64;
+ SysUtils, m_api;
const
DIGEST_DIV = '-';
@@ -71,18 +71,25 @@ const function DigToBase(Digest: TDig64): AnsiString;
var
DigStr: AnsiString;
+ EncodedStr: PAnsiChar;
begin
SetLength(DigStr, SizeOf(Digest));
Move(Digest, DigStr[1], SizeOf(Digest));
- Result := Base64EncodeStr(DigStr);
+ EncodedStr := mir_base64_encode(PByte(@DigStr[1]), Length(DigStr));
+ Result := EncodedStr;
+ mir_free(EncodedStr);
end;
function BaseToDig(const Str: AnsiString): TDig64;
var
DigStr: AnsiString;
+ BufLen: int;
+ Buf: PByte;
begin
- DigStr := Base64DecodeStr(Str);
- Move(DigStr[1], Result, SizeOf(Result));
+ Buf := mir_base64_decode(PAnsiChar(Str), BufLen);
+ if (BufLen = SizeOf(Result)) then
+ Move(Buf^, Result, SizeOf(Result));
+ mir_free(Buf);
end;
function HashString(const Str: AnsiString): TDig64;
@@ -90,27 +97,8 @@ begin Result := ZeroDig;
Result[0] := InitCRC;
CalcCRC32(@Str[1], Length(Str), Result[0]);
- // CalcSampleHash(@Str[1],Length(Str),Result);
end;
-(*
-function StrToDig(Str: AnsiString): TDig64;
-var
- Dig1, Dig2: AnsiString;
- n: Integer;
-begin
- Result[0] := 0;
- Result[1] := 0;
- n := Pos(DIGEST_DIV, Str);
- if n = 0 then
- exit;
- Dig1 := Copy(Str, 1, n - 1);
- Dig2 := Copy(Str, n + 1, Length(Str));
-
- Result[0] := StrToInt('$' + Dig1);
- Result[1] := StrToInt('$' + Dig2);
-end;
-*)
function DigToStr(Digest: TDig64): AnsiString;
begin
Result := AnsiString(IntToHex(Digest[0], 8)) + DIGEST_DIV + AnsiString(IntToHex(Digest[1], 8));
diff --git a/plugins/HistoryPlusPlus/historypp.dpr b/plugins/HistoryPlusPlus/historypp.dpr index 2430605be8..1cd1c7908a 100644 --- a/plugins/HistoryPlusPlus/historypp.dpr +++ b/plugins/HistoryPlusPlus/historypp.dpr @@ -68,7 +68,6 @@ uses hpp_richedit in 'hpp_richedit.pas',
hpp_olesmileys in 'hpp_olesmileys.pas',
HistoryControls in 'HistoryControls.pas',
- Base64 in 'Base64.pas',
Checksum in 'Checksum.pas',
hpp_JclSysUtils in 'hpp_JclSysUtils.pas',
hpp_puny in 'hpp_puny.pas';
diff --git a/plugins/HistoryPlusPlus/historypp.dproj b/plugins/HistoryPlusPlus/historypp.dproj index b11475abd0..41a02928e5 100644 --- a/plugins/HistoryPlusPlus/historypp.dproj +++ b/plugins/HistoryPlusPlus/historypp.dproj @@ -176,7 +176,6 @@ <DCCReference Include="hpp_richedit.pas"/>
<DCCReference Include="hpp_olesmileys.pas"/>
<DCCReference Include="HistoryControls.pas"/>
- <DCCReference Include="Base64.pas"/>
<DCCReference Include="Checksum.pas"/>
<DCCReference Include="hpp_JclSysUtils.pas"/>
<DCCReference Include="hpp_puny.pas"/>
|