Skip to content

Instantly share code, notes, and snippets.

@nikoheikkila
Created February 18, 2012 18:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikoheikkila/1860425 to your computer and use it in GitHub Desktop.
Save nikoheikkila/1860425 to your computer and use it in GitHub Desktop.
Python: hwmodule-0.1
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