from hashlib import sha1 __author__ = 'diraven' # Define simple checksum function for string lists def sha1_list(target): result = '' for item in target: result = result + item return sha1(result).hexdigest() # Define function that will do testing def test(list1, list2): print 'list1: %s' % list1 print 'list2: %s' % list2 print 'list1 sha1: %s' % sha1_list(list1) print 'list2 sha1: %s' % sha1_list(list2) print 'list1 and list2 produce the same result: %s' % (sha1_list(list1) == sha1_list(list2)) print "" # Make new list list1 = [] # Add few test strings list1.append('test') list1.append('test2') list1.append('test3') list1.append('test45') list1.append('test68') # Make another list list2 = [] # Add same strings list2.append('test') list2.append('test2') list2.append('test3') list2.append('test45') list2.append('test68') # Calculate checksums for these two lists test(list1, list2) # Remove some elements from list2 del list2[2] del list2[1] # Calculate checksums for these two lists again test(list1, list2)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question