NET API
HSM Dinamo
Loading...
Looking for...
No entries found
generate_hash.cs

Example of the use of HASH generation.

See Note on examples.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dinamo;
using Dinamo.Hsm;
namespace GenerateHASH
{
class Program
{
static void Main(string[] args)
{
string address = "10.0.0.1";
string user = "master";
string pass = "12345678";
//Conecta ao HSM
din.Connect(address, user, pass);
byte []message1 = new byte[]
{
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38
};
byte []message2 = new byte[]
{
0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
};
Console.Out.WriteLine("Generate HASH in one call.\n");
byte[] hash = din.generateHash(DinamoClient.HASH_ALG.ALG_SHA2_256, message1);
Console.Out.WriteLine("hash: {0}\n", BitConverter.ToString(hash).Replace("-", string.Empty));
Console.Out.WriteLine("Generate HASH in multiple calls.\n");
din.initHash(DinamoClient.HASH_ALG.ALG_SHA2_256);
din.updateHash(message1);
din.updateHash(message2);
byte[] hash2 = din.endMAC();
Console.Out.WriteLine("hash2: {0}\n", BitConverter.ToString(hash2).Replace("-", string.Empty));
din.Disconnect();
}
}
}
API class for accessing HSM functionalities Dinamo. In this class you can program using...
Definition DinamoClient.cs:93
HASH_ALG
Hash algorithm for signatures.
Definition DinamoClient.cs:137
void initHash(HASH_ALG AlgId, int Flags)
Initializes a HASH operation in parts. It must be finalized with endHash.
Definition DinamoClient.cs:3877
byte[] endMAC()
Ends a MAC operation.
Definition DinamoClient.cs:3859
void updateHash(byte[] Data)
Updates a HASH operation with more data.
Definition DinamoClient.cs:3900
byte[] generateHash(HASH_ALG AlgId, byte[] Data, int Flags)
Generates a HASH in just one call.
Definition DinamoClient.cs:3771
void Connect(string User, string Password)
Establishes an encrypted connection to the HSM using the load balance settings.
Definition DinamoClient.cs:562
void Disconnect(bool flagClose)
Terminates the connection to the HSM.
Definition DinamoClient.cs:814
Namespace denoting a set of functions for accessing the HSM Dinamo and their respective exceptions.
Definition DinamoClient.cs:12
Definition DinamoClient.cs:12