Skip to content

Instantly share code, notes, and snippets.

@amrali
Created September 2, 2012 08:01
Show Gist options
  • Save amrali/3595732 to your computer and use it in GitHub Desktop.
Save amrali/3595732 to your computer and use it in GitHub Desktop.
Get public key's fingerprint in CoffeeScript
crypto = require 'crypto'
md5sum = crypto.createHash 'md5'
pkey = 'Base64 encoded public key goes here'
data = Buffer(key, 'base64').toString 'binary'
md5sum.update data
fingerprint = md5sum.digest 'hex'
fingerprint = ("#{fingerprint[i]}#{fingerprint[i + 1]}" for i in [0...fingerprint.length] when i % 2 is 0).join ':'
# `fingerprint` now contains the colon separated hexadecimal fingerprint
# (e.g., 2f:2d:44:61:3f:11:7c:9e:b5:f1:c3:55:bf:08:ee:fd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment