Learn R Programming

digest (version 0.6.29)

digest2int: hash arbitrary string to integer

Description

The digest2int function calculates integer hash of an arbitrary string. This is useful for randomized experiments, feature hashing, etc.

Usage

digest2int(x, seed = 0L)

Value

The digest2int function returns integer vector of the same length as input vector x.

Arguments

x

An arbitrary character vector.

seed

an integer for algorithm initial state. Function will produce different hashes for same input and different seed values.

Author

Dmitriy Selivanov selivanov.dmitriy@gmail.com for the R interface; Bob Jenkins for original implementation http://www.burtleburtle.net/bob/hash/doobs.html

References

Jenkins's one_at_a_time hash: https://en.wikipedia.org/wiki/Jenkins_hash_function#one_at_a_time.

See Also

digest

Examples

Run this code

current <- digest2int("The quick brown fox jumps over the lazy dog", 0L)
target <- 1369346549L
stopifnot(identical(target, current))

Run the code above in your browser using DataLab