Page MenuHomeClusterLabs Projects
Diviner Tech Docs PhabricatorHash

final class PhabricatorHash
Phorge Technical Documentation ()

This class is not documented.

Methods

public static function weakDigest($string, $key)

Digest a string using HMAC+SHA1.

Because a SHA1 collision is now known, this method should be considered weak. Callers should prefer digestWithNamedKey().

Parameters
string$stringInput string.
$key
Return
string32-byte hexadecimal SHA1+HMAC hash.

public static function digestForIndex($string)

Digest a string for use in, e.g., a MySQL index. This produces a short (12-byte), case-sensitive alphanumeric string with 72 bits of entropy, which is generally safe in most contexts (notably, URLs).

This method emphasizes compactness, and should not be used for security related hashing (for general purpose hashing, see digest()).

Parameters
string$stringInput string.
Return
string12-byte, case-sensitive, mostly-alphanumeric hash of the string.

public static function digestForAnchor($string)

Digest a string for use in HTML page anchors. This is similar to digestForIndex() but produces purely alphanumeric output.

This tries to be mostly compatible with the index digest to limit how much stuff we're breaking by switching to it. For additional discussion, see T13045.

Parameters
string$stringInput string.
Return
string12-byte, case-sensitive, purely-alphanumeric hash of the string.

public static function digestToRange($string, $min, $max)

This method is not documented.
Parameters
$string
$min
$max
Return
wild

public static function digestToLength($string, $length)

Shorten a string to a maximum byte length in a collision-resistant way while retaining some degree of human-readability.

This function converts an input string into a prefix plus a hash. For example, a very long string beginning with "crabapplepie..." might be digested to something like "crabapp-N1wM1Nz3U84k".

This allows the maximum length of identifiers to be fixed while maintaining a high degree of collision resistance and a moderate degree of human readability.

Parameters
string$stringThe string to shorten.
int$lengthMaximum length of the result.
Return
stringString shortened in a collision-resistant way.

public static function digestWithNamedKey($message, $key_name)

This method is not documented.
Parameters
$message
$key_name
Return
wild

public static function digestHMACSHA256($message, $key)

This method is not documented.
Parameters
$message
$key
Return
wild

private static function getNamedHMACKey($hmac_name)

This method is not documented.
Parameters
$hmac_name
Return
wild

private static function newHMACKey($hmac_name)

This method is not documented.
Parameters
$hmac_name
Return
wild

private static function writeHMACKey($hmac_name, $hmac_key)

This method is not documented.
Parameters
$hmac_name
$hmac_key
Return
wild

private static function readHMACKey($hmac_name)

This method is not documented.
Parameters
$hmac_name
Return
wild