EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Access to underlying hash functions?

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#15998
Posted: 03/07/2011 21:19:11
by Eric Lenington (Standard support level)
Joined: 12/06/2010
Posts: 37

Is it possible to access the hash functions in SBB directly? I have a need to hash a simple in-memory string with SHA256 (or similar hash) and it seems silly to have to use another library when SBB has these functions internally.
#15999
Posted: 03/08/2011 02:02:37
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi. You can use TElHashFunction for such purpose : https://www.eldos.com/documentation/sbb/documentation/ref_cl_hashfunction.html
#16006
Posted: 03/08/2011 07:50:00
by Eric Lenington (Standard support level)
Joined: 12/06/2010
Posts: 37

Yep, that's what I was looking for. I was able to find the class in the SBB help file in the Index, but it may be missing from the Contents (is it there somewhere, but I'm missing it?)

Also, do you have a quick example of using this class to hash a string?
#16008
Posted: 03/08/2011 08:20:50
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

It should be something like the following:
Code
var
  hashFunction : TElHashFunction;
  data : ByteArray;
  hashedString : string;
  hash : BufferType;
begin
  hashedString := 'Hello, world!';
  hashFunction := TElHashFunction.Create(SB_ALGORITHM_DGST_SHA256);
  hashFunction.Update(@hashedString[1], Length(hashedString) * SizeOf(hashedString[1])); // to make it work with ansi/unicode strings
  hash := hashFunction.Finish;
end;

After all you may need to convert hash into hex representation.
#16009
Posted: 03/08/2011 08:35:03
by Eric Lenington (Standard support level)
Joined: 12/06/2010
Posts: 37

Perfect. Thanks!
#16012
Posted: 03/08/2011 10:52:13
by Eugene Mayevski (EldoS Corp.)

Quote
Mykola Olshevsky wrote:
hashFunction.Update(@hashedString[1], Length(hashedString) * SizeOf(hashedString[1])); // to make it work with ansi/unicode strings


it's simpler to check sizeof(Char) .


Sincerely yours
Eugene Mayevski
#16014
Posted: 03/08/2011 13:36:19
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

And, about help file - ElHashFunction documentation can be found at Reference->PKI->Low-level cryptography->Symmetric->ElHashFunction class
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 1175 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!