Andreas Software - Källkod - KSADLL.PAS

Ladda min lilla DLL-fil KSA.DLL / KSA-X86.DLL dynamiskt i Embarcadero Delphi och använd den för att skapa krypteringsnycklar från lösenord

unit KSADLL;

{
  Dynamically load my little DLL file KSA.DLL / KSA-X86.DLL in Embarcadero Delphi and use it to make encryption keys from passwords. It's a key strengthening algorithm that uses SHA-3 and it performs 1 + (IntStrength * 1024) number of hashes. Valid numbers for IntStrength are 32, 64, 128, 256, 512 and 1024. Valid numbers for IntBits are 224, 256, 384 and 512. The returned string is hex encoded. The DLL file is Unicode and is available in both x64 and x86 variants. Download the DLL files here:

  https://www.andreas-software.com/KSA.DLL.ZIP

  https://www.andreas-software.com/KSA-X86.DLL.ZIP

  Original Author: Andreas Jonsson. (www.andreas-software.com)

  NOTICE: YOU MAY USE AND MODIFY THIS SOURCE CODE FREELY, THE ONLY REQUIREMENT IS THAT THE COMMENT ABOUT THE ORIGINAL AUTHOR AND THIS NOTICE REMAINS IN THE SOURCE CODE.
}

interface

uses
  Winapi.Windows, Winapi.Messages,
  System.SysUtils, System.Variants, System.Classes;

function MakeKSAHexKey(StrPassword: string; IntStrength: NativeInt = 128; IntBits: NativeInt = 256): string;

implementation

type
  TMakeKSAHexKeyFunction = function(StrPassword: PWideChar; IntStrength: NativeInt; IntBits: NativeInt; OutputBuffer: Pointer): NativeInt; stdcall;

function MakeKSAHexKey(StrPassword: string; IntStrength: NativeInt = 128; IntBits: NativeInt = 256): string;
var DLLFileName: string;
var DLLFunctionName: string;
var DLLHandle: NativeUInt;
var MakeKSAHexKeyFunction: TMakeKSAHexKeyFunction;
begin
  Result := '';
  if StrPassword <> '' then begin
    if (IntStrength = 32) or (IntStrength = 64) or (IntStrength = 128) or (IntStrength = 256) or (IntStrength = 512) or (IntStrength = 1024) then begin
      if (IntBits = 224) or (IntBits = 256) or (IntBits = 384) or (IntBits = 512) then begin
        DLLFileName := 'KSA';
        {$IFDEF WIN32}
          DLLFileName := DLLFileName + '-X86';
        {$ENDIF}
        DLLFileName := DLLFileName + '.DLL';
        DLLFunctionName := 'MakeKSAHexKey';
        DLLHandle := LoadLibrary(PWideChar(DLLFileName));
        if DLLHandle <> 0 then begin
          @MakeKSAHexKeyFunction := GetProcAddress(DLLHandle, PWideChar(DLLFunctionName));
          if Assigned(MakeKSAHexKeyFunction) = True then begin
            SetLength(Result, (IntBits div 8) * 2);
            if MakeKSAHexKeyFunction(PWideChar(StrPassword), IntStrength, IntBits, Pointer(Result)) = (((IntBits div 8) * 2) * 2) then begin
              // OK.
            end
            else begin
              Result := '';
            end;
          end;
          FreeLibrary(DLLHandle);
        end;
      end;
    end;
  end;
end;

end.

⎙ Skriv ut KSADLL.PAS

Du kan även visa källkoden som ren text, KSADLL.PAS.TXT.

Källkoden är relaterad till RandomDLL.PAS.

www.andreas-software.com

Copyright © 1998-2021, Andreas Jönsson. Alla rättigheter reserverade.

In English?
View this page in English