internet data handling and encoding normallythe initial key value is determined at random using cryptographically strong random number generator an hmac objecthhas the following methodsh update(msgadds the string msg to the hmac object digest(returns the digest of all data processed so far and returns byte string containing the digest value the length of the string depends on the underlying hashing function for md it is charactersfor sha- it is characters hexdigest(returns the digest as string of hexadecimal digits copy(makes copy of the hmac object example the primary use of the hmac module is in applications that need to authenticate the sender of message to do thisthe key parameter to new(is byte string representing secret key known by both the sender and receiver of message when sending messagethe sender will create new hmac object with the given keyupdate the object with message data to be sentand then send the message data along with the resulting hmac digest value to the receiver the receiver can verify the message by computing its own hmac digest value (using the same key and message dataand comparing the result to the digest value received here is an exampleimport hmac secret_key "peekaboodata "hello worldbyte string only known to me typically you would want to use string of random bytes computed using os urandom(or similar the message to send send the message somewhere out represents socket or some other / channel on which we are sending data hmac new(secret_keyh update(dataout send(datasend the data out send( digest()send the digest receive the message in represents socket or some other / channel out which we are receiving data hmac new(secret_keydata in receive(get the message data update(datadigest in receive(get the digest sent by the sender if digest ! digest()raise authenticationerror('message not authenticated' lib fl ff