Advanced _SHA2 (256 & 512) - Chewhern/ASodium GitHub Wiki
For detailed documentation, kindly refer to official libsodium.
SHA256
Single message hashing
Initial Functions
public static Byte[] ComputeHash(Byte[] Message)
Example Code
Byte[] RandomMessage = SodiumRNG.GetRandomBytes(128);
Byte[] ComputedHash = SodiumHashSHA256.ComputeHash(RandomMessage);
Multiple message hashing
Initial Functions
public static Byte[] InitializeState()
public static Byte[] UpdateState(Byte[] State, Byte[] Message)
public static Byte[] ComputeHashForFinalizedState(Byte[] State)
Example Code
Byte[] RandomMessage1 = SodiumRNG.GetRandomBytes(128);
Byte[] RandomMessage2 = SodiumRNG.GetRandomBytes(128);
Byte[] RandomMessage3 = SodiumRNG.GetRandomBytes(128);
Byte[] State = SodiumHashSHA256.InitializeState();
State = SodiumHashSHA256.UpdateState(State, RandomMessage1);
State = SodiumHashSHA256.UpdateState(State, RandomMessage2);
State = SodiumHashSHA256.UpdateState(State, RandomMessage3);
Byte[] ComputedHash = SodiumHashSHA256.ComputeHashForFinalizedState(State);
SHA512
Single message hashing
Initial Function
public static Byte[] ComputeHash(Byte[] Message)
Example Code
Byte[] RandomMessage = SodiumRNG.GetRandomBytes(128);
Byte[] ComputedHash = SodiumHashSHA512.ComputeHash(RandomMessage);
Multiple message hashing
Initial Functions
public static Byte[] InitializeState()
public static Byte[] UpdateState(Byte[] State, Byte[] Message)
public static Byte[] ComputeHashForFinalizedState(Byte[] State)
Example Code
Byte[] RandomMessage1 = SodiumRNG.GetRandomBytes(128);
Byte[] RandomMessage2 = SodiumRNG.GetRandomBytes(128);
Byte[] RandomMessage3 = SodiumRNG.GetRandomBytes(128);
Byte[] State = SodiumHashSHA512.InitializeState();
State = SodiumHashSHA512.UpdateState(State, RandomMessage1);
State = SodiumHashSHA512.UpdateState(State, RandomMessage2);
State = SodiumHashSHA512.UpdateState(State, RandomMessage3);
Byte[] ComputedHash = SodiumHashSHA512.ComputeHashForFinalizedState(State);