Created
February 18, 2012 18:04
-
-
Save nikoheikkila/1860425 to your computer and use it in GitHub Desktop.
Python: hwmodule-0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys, hashlib | |
# -*- coding: utf-8 -*- | |
def encryptMAC(address): | |
''' Generate MD5 checksum from unicode physical address ''' | |
try: | |
# Calculate checksum | |
print("Calculating, please wait...", end="\n") | |
checksum = hashlib.md5(address.encode('utf-8')) | |
return checksum.hexdigest() | |
# Validate input data | |
except (AttributeError) as err: | |
print("Fatal error: " + str(err), file=sys.stderr) | |
finally: | |
pass | |
# TEST CASE | |
print(encryptMAC("0123456789AB")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment