You are on page 1of 2

DIGITAL ASSISIGNMENT-4

NAME:- P. PRANEETH REDDY


REG NO:- 19BCI0154
Slot:-L33+L34
Activity4:

1. SHA-1 is a popular heuristic hash function that is currently in trend. In this experiment, we shall
familiarize ourselves with SHA-1 as well as look at one important application of hashing, namely,
the HMAC algorithm which is currently used in the Internet to achieve data integrity.

Code (Hashing with SHA1 in Message authentication Code):

m
er as
# Method 1: Using hashlib and hmac modules

co
import hashlib

eH w
import hmac

o.
def make_digest(message, key):
rs e
ou urc
# converting into bytes
key = bytes(key, 'UTF-8')
o

message = bytes(message, 'UTF-8')


aC s
vi y re

# creating signature from the digest using sha1


digester = hmac.new(key, message, hashlib.sha1)
signature1 = digester.hexdigest()
ed d

#signature1 = digester.digest()
ar stu

print("Hexdigest: ",signature1)

# other functions to display details


is

print ("Digest size is(in bytes): " + str(digester.digest_size))


print ("Block size is(in bytes): " + str(digester.block_size))
Th

print ("Canonical name(encryption Algorithm used): " + digester.name)

# main function
sh

message=input("Enter the message(used in SHA1): ")


key=input("Enter the key(used in MAC): ")
make_digest(message,key)

This study source was downloaded by 100000832904401 from CourseHero.com on 10-12-2021 07:47:25 GMT -05:00

https://www.coursehero.com/file/81941350/19BCI0154-VL2020210104340-AST04-1pdf/
Output:

m
er as
co
eH w
o.
rs e
ou urc
o
aC s
vi y re
ed d
ar stu
is
Th
sh

This study source was downloaded by 100000832904401 from CourseHero.com on 10-12-2021 07:47:25 GMT -05:00

https://www.coursehero.com/file/81941350/19BCI0154-VL2020210104340-AST04-1pdf/
Powered by TCPDF (www.tcpdf.org)

You might also like