Recent

Author Topic: HashLib4Pascal  (Read 34031 times)

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: HashLib4Pascal
« Reply #45 on: May 27, 2019, 08:40:25 pm »
Yes it's true, blake2b is faster on 64bit and blake2s is faster on 32bit.

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: HashLib4Pascal
« Reply #46 on: May 30, 2019, 09:26:40 am »
updated to version 3.6

- changelog

* fixed bug in Shake128 and Shake256 for large output sizes
* add Keccak288 support
* add full support for tree hashing mode in Blake2b and Blake2s as per python's HashLib specification.

** now updated in OPM
« Last Edit: May 30, 2019, 11:21:43 am by Xor-el »

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: HashLib4Pascal
« Reply #47 on: May 30, 2019, 09:32:50 am »
keccak = sha3?
« Last Edit: May 30, 2019, 10:04:23 am by Thaddy »
Specialize a type, not a var.

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: HashLib4Pascal
« Reply #48 on: May 30, 2019, 10:43:16 am »
keccak = sha3?

nope, Keccak is the original implementation before NIST made a modification to the finalization padding bit from 0x1 to 0x6 which resulted in SHA3. implementation wise, they are very similar but output is totally different.
« Last Edit: May 30, 2019, 10:50:46 am by Xor-el »

totya

  • Hero Member
  • *****
  • Posts: 720
Re: HashLib4Pascal
« Reply #49 on: June 07, 2019, 10:21:09 pm »
Hi!

I'd like selectable hash algorithm, so I use common variable for it:

Code: Pascal  [Select][+][-]
  1. var Hash: IHash;

and for example:
Code: Pascal  [Select][+][-]
  1. Hash := THashFactory.TCrypto.CreateBlake2S_256();

So, can I use this next line with IHash variable?
Code: Pascal  [Select][+][-]
  1. Hash := THashFactory.THash32.CreateXXHash32;

Because as I see the result is IHashWithKey
Code: Pascal  [Select][+][-]
  1. class function THashFactory.THash32.CreateXXHash32: IHashWithKey;

Thanks!

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: HashLib4Pascal
« Reply #50 on: June 07, 2019, 11:54:12 pm »
Hi!

I'd like selectable hash algorithm, so I use common variable for it:

Code: Pascal  [Select][+][-]
  1. var Hash: IHash;

and for example:
Code: Pascal  [Select][+][-]
  1. Hash := THashFactory.TCrypto.CreateBlake2S_256();

So, can I use this next line with IHash variable?
Code: Pascal  [Select][+][-]
  1. Hash := THashFactory.THash32.CreateXXHash32;

Because as I see the result is IHashWithKey
Code: Pascal  [Select][+][-]
  1. class function THashFactory.THash32.CreateXXHash32: IHashWithKey;

Thanks!

Code: Pascal  [Select][+][-]
  1. IHashWithKey
inherits from
Code: Pascal  [Select][+][-]
  1. IWithKey
which inherits from
Code: Pascal  [Select][+][-]
  1. IHash
so yes
Code: Pascal  [Select][+][-]
  1. Hash := THashFactory.THash32.CreateXXHash32;
is assignment compatible to
Code: Pascal  [Select][+][-]
  1. IHash
and can be used.
You only need to care about
Code: Pascal  [Select][+][-]
  1. IHashWithKey
if you want to use a different Key from the default that is made available internally.

totya

  • Hero Member
  • *****
  • Posts: 720
Re: HashLib4Pascal
« Reply #51 on: June 08, 2019, 11:04:43 am »
Thank you for the answer!  :)

The ZipGenius Team

  • New member
  • *
  • Posts: 7
Re: HashLib4Pascal
« Reply #52 on: September 09, 2019, 05:37:24 pm »
Hello.
I'm trying to use HashLib4Pascal to hash a string using Shake-256. I wrote this sample test code but it produces nothing (an empty string). Am I missing anything?

Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  3.   HlpIHash, HlpIHashResult, HlpSHA3;
  4.  
  5. ...
  6.  
  7. procedure TForm1.Button1Click(Sender: TObject);
  8. var
  9.  cHash: IHash;
  10.  Value : string;
  11. begin
  12.   cHash := TShake_256.Create();
  13.   Value := cHash.ComputeString(Edit1.Text, TEncoding.UTF8).ToString();
  14.   Memo1.lines.Clear;
  15.   Memo1.lines.Text:=Value;
  16. end;
  17.  

Thanks!
« Last Edit: September 09, 2019, 05:43:03 pm by The ZipGenius Team »
Matteo Riso
http://www.zipgenius.it
Happy ZipGenius User #1

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: HashLib4Pascal
« Reply #53 on: September 09, 2019, 07:42:47 pm »
Hello.
I'm trying to use HashLib4Pascal to hash a string using Shake-256. I wrote this sample test code but it produces nothing (an empty string). Am I missing anything?
Code: Pascal  [Select][+][-]
  1.    cHash := THashFactory.TShake_256.Create();
Specialize a type, not a var.

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: HashLib4Pascal
« Reply #54 on: September 09, 2019, 08:06:29 pm »
Hello.
I'm trying to use HashLib4Pascal to hash a string using Shake-256. I wrote this sample test code but it produces nothing (an empty string). Am I missing anything?

Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  3.   HlpIHash, HlpIHashResult, HlpSHA3;
  4.  
  5. ...
  6.  
  7. procedure TForm1.Button1Click(Sender: TObject);
  8. var
  9.  cHash: IHash;
  10.  Value : string;
  11. begin
  12.   cHash := TShake_256.Create();
  13.   Value := cHash.ComputeString(Edit1.Text, TEncoding.UTF8).ToString();
  14.   Memo1.lines.Clear;
  15.   Memo1.lines.Text:=Value;
  16. end;
  17.  

Thanks!

Hi,
You do have to understand that shake256 is a XOF https://en.m.wikipedia.org/wiki/Category:Extendable-output_functions so it can output variable length output based on your input.
Unfortunately, you didn't specify what output size you wanted that's why your output is empty.
In this example below, I will use output XOF size as 256 bits (32 bytes)

Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  3.   HlpIHash, HlpHashFactory;
  4.  
  5. ...
  6.  
  7. procedure TForm1.Button1Click(Sender: TObject);
  8. var
  9.  cHash: IHash;
  10.  Value : string;
  11. begin
  12.   cHash := THashFactory.TXOF.CreateShake_256(256);
  13.   Value := cHash.ComputeString(Edit1.Text, TEncoding.UTF8).ToString();
  14.   Memo1.lines.Clear;
  15.   Memo1.lines.Text:=Value;
  16. end;
  17.  

The ZipGenius Team

  • New member
  • *
  • Posts: 7
Re: HashLib4Pascal
« Reply #55 on: September 10, 2019, 11:36:05 am »
Hi,
You do have to understand that shake256 is a XOF https://en.m.wikipedia.org/wiki/Category:Extendable-output_functions so it can output variable length output based on your input.
Unfortunately, you didn't specify what output size you wanted that's why your output is empty.
In this example below, I will use output XOF size as 256 bits (32 bytes)

Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  3.   HlpIHash, HlpHashFactory;
  4.  
  5. ...
  6.  
  7. procedure TForm1.Button1Click(Sender: TObject);
  8. var
  9.  cHash: IHash;
  10.  Value : string;
  11. begin
  12.   cHash := THashFactory.TXOF.CreateShake_256(256);
  13.   Value := cHash.ComputeString(Edit1.Text, TEncoding.UTF8).ToString();
  14.   Memo1.lines.Clear;
  15.   Memo1.lines.Text:=Value;
  16. end;
  17.  

Thank you very much! That was what I was looking for. In fact, that's what I did some time ago when I had to develop in C# using BouncyCastle. Unfortunately, I didn't find any example regarding Shake.
Thanks again :)
Matteo Riso
http://www.zipgenius.it
Happy ZipGenius User #1

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: HashLib4Pascal
« Reply #56 on: December 02, 2019, 11:14:57 pm »
updated to version 4.0

- changelog from 3.6 to 4.0
* add Scrypt support
* add CShake128 and CShake256 support
* add Blake2XS and Blake2XB XOF support
* add KMAC128 and KMAC256 (XOF) support
* add Blake2BMAC and Blake2SMAC support
* add Blake2BP and Blake2SP support
* performance enhancements in various hashes and checksums including but not limited to XXHash32, XXHash64, Siphash, MurmurHash, Adler32, CRC32 etc

** Now updated in OPM
« Last Edit: December 03, 2019, 06:52:37 am by Xor-el »

trevor

  • New Member
  • *
  • Posts: 10
Re: HashLib4Pascal
« Reply #57 on: January 20, 2020, 07:09:30 am »
Is it possible to make a password for Apache (like in htpasswd) with HashLib4Pascal:-\

trevor

  • New Member
  • *
  • Posts: 10
Re: HashLib4Pascal
« Reply #58 on: January 20, 2020, 07:22:44 am »
Is it possible to make a password for Apache (like in htpasswd) with HashLib4Pascal:-\

BTW I need a
Quote
"{SHA}" + Base64-encoded SHA-1 digest of the password
only (-nbs).

Thank you :)

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: HashLib4Pascal
« Reply #59 on: January 20, 2020, 08:20:32 am »
Is it possible to make a password for Apache (like in htpasswd) with HashLib4Pascal:-\
Hi trevor, what exact algorithms does Apache Password use and in what order is it used?

 

TinyPortal © 2005-2018