cboettig / contentid

:package: R package for working with Content Identifiers

Home Page:http://cboettig.github.io/contentid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should contentid recognize truncated hashes?

cboettig opened this issue · comments

as mentioned in #1, ni:// scheme officially recognizes truncating hashes, and comments that this might be useful for naming things (though technically indicates these should be listed as different hash algorithm indicating the length, e.g. sha256-128 would indicate truncation to length 128 bit, i.e. 22 chars in base64 or 32 in hex). hash-archive.org supports truncation of any hashes (and will simply return matches for multiple identifiers if you truncate way too much)

In cases like a print reference where a concise hash may be more important than cryptographic security, being able to use (and resolve) truncated hashes could be useful. But maybe this opens up more possible confusion and room for error?

how does it work for git commits? (there's a long and short ref)

Haven't looked at the internals but I believe it works in precisely the same way (i.e. you can truncate the ref just as much as you like provided that it uniquely resolves -- because of the way hash algorithms work the characters at the start of the hash are most important)