0% found this document useful (0 votes)
5 views2 pages

Nis Exp7

This document explains the concept of hash functions, which convert variable-length input into a fixed-length output and are primarily used for data integrity and security purposes. It provides an example of hashing the string 'Hello World' using the SHA1 function and discusses the applications of hash functions in programming, particularly in Python. The conclusion highlights the use of the hash method in Python for returning hash values of objects, aiding in dictionary key comparisons.

Uploaded by

ksai58701
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Nis Exp7

This document explains the concept of hash functions, which convert variable-length input into a fixed-length output and are primarily used for data integrity and security purposes. It provides an example of hashing the string 'Hello World' using the SHA1 function and discusses the applications of hash functions in programming, particularly in Python. The conclusion highlights the use of the hash method in Python for returning hash values of objects, aiding in dictionary key comparisons.

Uploaded by

ksai58701
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical No.

Aim: Create and Verify Hash Code for given message.


Introduction:
A hash function is a function that takes input of a variable
length sequence of bytes and converts it to a fixed length sequence. It
is a one way function. This means if f is the hashing function,
calculating f(x) is pretty fast and simple, but trying to obtain x again
will take years. The value returned by a hash function is often called a
hash, message digest, hash value, or checksum. Most of the time a
hash function will produce unique output for a given input. However
depending on the algorithm, there is a possibility to find a collision due
to the mathematical theory behind these functions.

Now suppose you want to hash the string "Hello Word" with the SHA1
Function, the result is 0a4d55a8d778e5022fab701977c5d840bbc486d0.

Hash functions are used inside some cryptographic algorithms, in


digital signatures, message authentication codes, manipulation
detection, fingerprints, checksums (message integrity check), hash
tables, password storage and much more. As a Python programmer
you may need these functions to check for duplicate data or files, to check
data integrity when you transmit information over a network, to securely
store passwords in databases, or maybe some work related to
cryptography.
Program:
#hash for integer unchanged

>>> print('Hash for 181


is:',hash(181)) #hash for
decimal
>>> print('Hash for 181.23
is:',hash(181.23)) #hash for
string
>>> print('Hash for Python is:',hash('Python'))

Output:

Conclusion:
Hash method in Python is a module that is used to return the hash
value of an object. In programming, the hash method is used to return
integer values that are used to compare dictionary keys using a dictionary
look up feature. When used, it calls for the hash () of an object
which is set by default during the creation of the object by the user.

You might also like