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

Example of signature generation.

See Note on examples.
using Dinamo.Hsm;
using System;
using System.Text;
namespace SignHashSample
{
class Program
{
static void Main(string[] args)
{
string address = "10.10.10.10"; // HSM address
string user = "user"; // HSM account user
string pass = "pwd"; // HSM account password
string keyId = "key_id"; // Key name
string message = "Test message ";
DinamoClient client = new DinamoClient();
// Conecta ao HSM
client.Connect(address, user, pass);
Console.Out.WriteLine("Connected");
var bMessage = Encoding.ASCII.GetBytes(message);
// Gera o hash
var hash = client. Hash(alg, bMessage);
Console.Out.WriteLine("Hash generated");
// Assina o hash
byte[] signature = client.SignHash(keyId, hash, alg);
Console.Out.WriteLine("Signature generated");
Console.Out.WriteLine("Assinatura:\n {0}", BitConverter.ToString(signature).Replace("-", string.Empty));
// Desconecta do HSM
client.Disconnect();
Console.Out.WriteLine("Disconnected");
}
}
}
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
byte[] SignHash(String keyId, byte[] bHash, DinamoClient.HASH_ALG algHash)
Sign a hash.
Definition DinamoClient.cs:4035
byte[] Hash(HASH_ALG alg, byte[] data)
Returns the hash of a piece of data.
Definition DinamoClient.cs:3964
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