Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hashing with Python Protecting Digital Evidence

Similar presentations


Presentation on theme: "Hashing with Python Protecting Digital Evidence"— Presentation transcript:

1 Hashing with Python Protecting Digital Evidence
Louai Rahal, MA, MSc May 2018

2 Hashing a word/sentence
#import the hashlib library import hashlib #Create a hash m = hashlib.md5() #add word/sentence to the hash m.update(b"Nobody inspects") #The b converts String to bytes #Print Hash print(m.hexdigest())

3 Reading a word or sentence from the user
#Read word sentence and store it in a variable input1 = input(“Enter any word or sentence”)

4 Hashing user’s input import hashlib #read input input1 = input("Enter any word or sentence") #convert input to bytes input2 = bytes(input1, 'utf-8') #Create a hash m = hashlib.md5() #add word/sentence to the hash m.update(input2) #Print Hash print(m.hexdigest())

5 Hashing user’s input import hashlib #read input input1 = input("Enter any word or sentence") #convert input to bytes input2 = bytes(input1, 'utf-8') #Create a hash m = hashlib.md5() #add word/sentence to the hash m.update(input2) #Print Hash print(m.hexdigest())

6 Hashing user’s input import hashlib #read input input1 = input("Enter any word or sentence") #convert input to bytes input2 = bytes(input1, 'utf-8') #Create a hash m = hashlib.sha1() #add word/sentence to the hash m.update(input2) #Print Hash print(m.hexdigest())

7 Other hashing algorithms include:
Hashing user’s input import hashlib #read input input1 = input("Enter any word or sentence") #convert input to bytes input2 = bytes(input1, 'utf-8') #Create a hash m = hashlib.sha1() #add word/sentence to the hash m.update(input2) #Print Hash print(m.hexdigest()) Other hashing algorithms include: sha1(), sha224(), sha256(), sha384(), sha512()

8 Create a Python Script that hashes a word entered by the user.
Hashing user’s input Create a Python Script that hashes a word entered by the user.

9 Hashing files allow us to create a digital fingerprint of the file
Next Objective: Hashing Files!! Rationale: Hashing files allow us to create a digital fingerprint of the file

10 “In order to verify the integrity of evidence [i. e
“In order to verify the integrity of evidence [i.e. that evidence has not been modified] digital fingerprinting is applied. This involves the use of a one way hash function” (Flaglien, 2018)

11 “The input to a hash function is a bit stream and the output is [a] unique hash” (Flaglien, 2018)

12 “By comparing the hashes of an original with those of its respective copy, one can verify that a copy is the exact same as the original” (Flaglien, 2018)

13 Creating a pointer to a file
file1 = open(‘filename.txt’, ‘r’) #use open(‘file.txt’,’rb’) for hashing print (file1.readline()) Print (file1.read()) Create two identical files: file1.txt and file2.txt, and one different file: file3.txt Hash the three files Compare the hash values

14 Open the file with the open() function
Create two identical files: file1.txt and file2.txt, and one different file: file3.txt Hash the three files Compare the hash values Hashing Files Open the file with the open() function Read the file with the read(“….”,”rb”) function Store the content of the file in a variable Hash the variable, there is no need to use the bytes() function here because the file is already read as bytes

15 http://www.dfrws.org/sites/default/files/session-files /paper-privacy-preserving_email_forensics.pdf
Reading Discussion “[n]o one shall be subjected to arbitrary interference with his privacy, […] or correspondence […] [and] [e]veryone has the right to the protection of the law against such interference or attacks” (International Community and U. N, 1948, Article 12). How can the content of s be investigated while respecting privacy. In groups, write a step by step procedure and send it to

16 file1 = open(‘f1.txt’, ‘r’) file2 = file1.read() if “hello” in file2:
Checking if a word is in a file file1 = open(‘f1.txt’, ‘r’) file2 = file1.read() if “hello” in file2: print(‘word found’) Choose any word from the English language Create two files (file1.txt and file2.txt), one that contains the word and one that does not contain the word Write a script that checks whether the word is in file1.txt and file2.txt


Download ppt "Hashing with Python Protecting Digital Evidence"

Similar presentations


Ads by Google