I dug around on the internet for a while trying to come up with an example of how to do this as I was having trouble with the documentation. I didn’t find many examples so I’m posting it here for anyone else that wants to do a similar thing.
Superfluous code removed…
import hashlib # For SHA-256 Encoding
Other Code Here...
with open(file_name) as f:
m = hashlib.sha256()
sha = m.digest()
res = base64.b64encode(sha)
Pretty easy… Now you can store this in Django inside a model like this:
hash = models.CharField(max_length=44L, unique=True )