Skip to contents

Hashes strings (a normalised URL, a title and year) into short identifiers, for sources that give none. The same string always gives the same identifier, on any machine.

Usage

hash_id(x, n = 12L, algo = "md5")

Arguments

x

Character. Strings to hash (normalise them first, e.g. URLs without tracking parameters).

n

Integer. Number of hexadecimal characters kept (12 characters give 16^12, about 2.8e14, values: collisions are negligible below millions of records).

algo

Character. Hash algorithm passed to digest::digest().

Value

A character vector (NA where x is NA).

See also

Other identifiers: make_doc_id(), make_slug(), pad_id()

Examples

hash_id(c("https://www.bis.org/publ/work1234.htm", NA))
#> [1] "6f80224d6b07" NA