Generate a key for the HMAC-SHA1 keyed-hashing algorithm : Key Generator « Security « Java






Generate a key for the HMAC-SHA1 keyed-hashing algorithm

    

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class Main {
  public static void main(String[] argv) throws Exception {

    KeyGenerator keyGen = KeyGenerator.getInstance("HmacMD5");
    SecretKey key = keyGen.generateKey();

    // Generate a key for the HMAC-SHA1 keyed-hashing algorithm
    keyGen = KeyGenerator.getInstance("HmacSHA1");
    key = keyGen.generateKey();
  }
}

   
    
    
    
  








Related examples in the same category

1.Using the KeyGenerator class and showing how to create a SecretKeySpec from an encoded key
2.Key Generator Mac
3.Generate DSA key pair
4.KeyPair Generator For Private Key
5.KeyPair Generator For Public Key
6.Wrap And Unwrap Key
7.Generating a Public/Private Key Pair
8.Generate a 576-bit DH key pair
9.Generate a 1024-bit RSA key pair
10.Getting the Bytes of a Generated Key Pair
11.Get the bytes of the public and private keys
12.The bytes can be converted back to public and private key objects
13.Asymmetric Key Maker
14.Generating a Symmetric Key
15.Xml dap Certs And Keys
16.Diffie-Hellman key exchange