HmacBytesFromBytes Method |
Create a keyed-hash HMAC in byte format from byte input.
Namespace: CryptoSysPKIAssembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.25611 (23.0.0.0)
Syntaxpublic static byte[] BytesFromBytes(
byte[] message,
byte[] key,
HashAlgorithm hashAlg
)
Public Shared Function BytesFromBytes (
message As Byte(),
key As Byte(),
hashAlg As HashAlgorithm
) As Byte()
Parameters
- message Byte
- Message to be signed in byte format
- key Byte
- Key in byte format
- hashAlg HashAlgorithm
- Hash algorithm to be used
Return Value
ByteHMAC in byte format
ExampleConsole.WriteLine("HMAC Test case 4 from RFC 2202 and RFC 4231...");
int i;
byte[] key = new byte[25];
for (i = 0; i < 25; i++)
key[i] = (byte)(i + 1);
byte[] msg = new byte[50];
for (i = 0; i < 50; i++)
msg[i] = 0xcd;
byte[] b = Hmac.BytesFromBytes(msg, key, HashAlgorithm.Sha256);
Console.WriteLine("HMAC-SHA-256(50(0xcd), 0x0102..19)=\n{0}", Cnv.ToHex(b));
See Also