Nix Hash: Difference between revisions
added BLAKE3 to the list of supported algorithms |
m →Libraries: Add new PHP library |
||
| (One intermediate revision by one other user not shown) | |||
| Line 4: | Line 4: | ||
Supported algorithms are <code>md5</code>, <code>sha1</code>, <code>sha256</code>, <code>sha512</code>, <code>BLAKE3</code>. The first two are deprecated and should not be used anymore, but you may still stumble upon them in existing code. | Supported algorithms are <code>md5</code>, <code>sha1</code>, <code>sha256</code>, <code>sha512</code>, <code>BLAKE3</code>. The first two are deprecated and should not be used anymore, but you may still stumble upon them in existing code. | ||
A hash – which is simply a sequence of bytes – is usually encoded in order to be representable as string. Common encodings are <code>base16</code> (commonly called "hex"), <code>base32</code> and <code>base64</code>. Note that the base32 is a [https://github.com/NixOS/nix/blob/ | A hash – which is simply a sequence of bytes – is usually encoded in order to be representable as string. Common encodings are <code>base16</code> (commonly called "hex"), <code>base32</code> and <code>base64</code>. Note that the base32 is a [https://github.com/NixOS/nix/blob/c70e1433abb61012dffdcd4559ec2aa87672e15c/src/libutil/hash.cc#L91-L112 '''custom one'''] that is not documented nor standardized in any way! If possible, use the provided hashing tools to convert hashes to it (see below). base32 is used by Nix in a lot of places because it is shorter than hex but can still safely be part of a file path (as it contains no slashes). | ||
== Usage == | == Usage == | ||
| Line 46: | Line 46: | ||
* [https://gist.github.com/colemickens/27ad622adfaf8c980f3b5066b21604ba Go implementation] | * [https://gist.github.com/colemickens/27ad622adfaf8c980f3b5066b21604ba Go implementation] | ||
* [https://github.com/dritter/nix-hasher/blob/master/src/Hasher.php#L18-L49 PHP Implementation] | * [https://github.com/dritter/nix-hasher/blob/master/src/Hasher.php#L18-L49 PHP Implementation] | ||
* [https://github.com/loophp/path-hasher PHP Implementation (NAR serialization + Hash)] | |||
== Further reading == | == Further reading == | ||