Generate key using generateKey() method of the KeyGenerator class as shown below. Initialize the KeyGenerator object created in the previous step using this method. The KeyGenerator class provides a method named init() this method accepts the SecureRandom object and initializes the current KeyGenerator. SecureRandom secRandom = new SecureRandom() The SecureRandom class of the java.Security package provides a strong random number generator which is used to generate random numbers in Java. KeyGenerator keyGen = KeyGenerator.getInstance("DES") The KeyGenerator class provides getInstance() method which accepts a String variable representing the required key-generating algorithm and returns a KeyGenerator object that generates secret keys.Ĭreate KeyGenerator object using the getInstance() method as shown below. Follow the steps given below to create message authentication code using this class. ![]() ![]() In Java the Mac class of the javax.crypto package provides the functionality of message authentication code. The process of using MAC for authentication is depicted in the following illustration − ![]() For establishing MAC process, the sender and receiver share a symmetric key K.Įssentially, a MAC is an encrypted checksum generated on the underlying message that is sent along with a message to ensure message authentication. MAC ( Message Authentication Code) algorithm is a symmetric key cryptographic technique to provide message authentication.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |