Commit 33c8a6db authored by Daniel Stan's avatar Daniel Stan

fpr: base64 decode avant

parent adf5a4c6
......@@ -55,11 +55,13 @@ def index(request):
def md5_format(pub_key):
"""Return md5 fingerprint, as shown by ssh"""
pub_key = base64.decodestring(pub_key)
fpr = hashlib.md5(pub_key).hexdigest()
return ':'.join(fpr[2*i] + fpr[2*i+1] for i in range(len(fpr)/2))
def sha256_format(pub_key):
"""Return sha256 fingerprint, as shown by ssh"""
pub_key = base64.decodestring(pub_key)
fpr = base64.encodestring(hashlib.sha256(pub_key).digest())
# some clean up
fpr = fpr.replace('=','').strip()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment