SecureBlackbox Lite 2020 Android Edition

Questions / Feedback?

HashFunction Component

Properties   Methods   Events   Configuration Settings   Errors  

The HashFunction component implements a wide variety of algorithms for message hashing.

Syntax

SecureBlackboxLite.Hashfunction

Remarks

HashFunction allows you to hash messages using a variety of industry standard hashing algorithms. Algorithms of both Hash and HMAC type are supported.

You can feed your data to HashFunction in one go, or in chunks. Use Hash method to initialize the hash function, pass the buffer, and calculate the hash in one line of code. Alternatively, use Reset, Update, and Finish in sequence to perform each of those steps individually. You can call Update (and its UpdateFile and UpdateStream variants) repeatedly between Reset and Finish, effectively passing the data in a number of portions:

  // Feeding the data in one go:
  Hashfunction hf = new Hashfunction();
  hf.Algorithm = "SHA256";
  byte[] hash = hf.Hash(buffer);

  // Feeding data chunk by chunk:
  Hashfunction hf = new Hashfunction();
  hf.Algorithm = "SHA256";
  hf.Reset(); 
  hf.Update(buffer1);
  hf.Update(buffer2);
  hf.Update(buffer3);
  byte[] hash = hf.Finish();

To use keyed HMAC, you need to provide the secret key first. Use CryptoKeyManager to create and initialize the key object:

  Cryptokeymanager km = new Cryptokeymanager();
  km.ImportBytes(hmacKey, Constants.kffDER, "SHA256", "", "", Constants.ktSecret);

  Hashfunction hf = new Hashfunction();
  hf.Algorithm = "SHA256";
  hf.Key = km.Key;
  byte[] hash = hf.Hash(buffer);

Use OutputEncoding to set the desired encoding method.

Property List


The following is the full list of the properties of the component with short descriptions. Click on the links for further details.

AlgorithmThe hash algorithm to use when hashing data.
InputStreamA stream containing the input data.
JsonSettingsProvides a container for JSON settings.
KeyThe key to use during the hashing.
OutputEncodingThe encoding to use for the output data.

Method List


The following is the full list of the methods of the component with short descriptions. Click on the links for further details.

configSets or retrieves a configuration setting.
finishCompletes the hash and returns the resulting message digest.
hashCalculates a message digest over a byte array.
hashFileCalculates a message digest over data contained in a file.
hashStreamCalculates a message digest over data contained in a stream.
resetResets the hash function context.
updateFeeds a chunk of data to the hash function.
updateFileFeeds the contents of a file to the hash function.
updateStreamFeeds the contents of a stream to the hash function.

Event List


The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.

ErrorInforms about errors during cryptographic operations.
NotificationThis event notifies the application about an underlying control flow event.

Configuration Settings


The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.

TempPathPath for storing temporary files.

Copyright (c) 2022 /n software inc. - All rights reserved.
SecureBlackbox Lite 2020 Android Edition - Version 20.0 [Build 8166]