Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
def smallAsciiRepresentation(digest)
digestParts = digest.unpack("Q2") # digest is a 128 bit buffer, cut it into two 64 bits ruby Integer
smallDigestPart = digestParts[0] ^ digestParts[1] # XOR the two 64 bits parts
smallDigest = [smallDigestPart].pack("Q") # and transform the result into a 64 bits binary buffer
smallDigestB64 = [smallDigest].pack("m") # b64-encode the result
smallID = smallDigestB64.gsub(/[\n=]/, '').gsub(/\+/,'-').gsub(/\//,'_') # and make it URL-friendly by shortening it (no '=' at the end, no '+', no '/')
return smallID
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.