How to get a hash code as integer in R?

That output is a hex (base 16) string. Use following function to change it to decimal. Taken from another forum post but link does not work anymore (2017).

hex_to_int = function(h) {
  xx = strsplit(tolower(h), "")[[1L]]
  pos = match(xx, c(0L:9L, letters[1L:6L]))
  sum((pos - 1L) * 16^(rev(seq_along(xx) - 1)))
}

Output

> hex_to_int(a)
[1] 1302704376

But better answer is strtoi: as @Andrie said and @Gedrox answered, base::strtoi function works in the same way.

strtoi("4da5b0f8", 16)
[1] 1302704376

There is a built in function base::strtoi:

> strtoi("4da5b0f8", 16)
[1] 1302704376

Since version 0.6.19, digest has a digest2int function, though there is no choice of algorithm. The algorithm used is Jenkin's one_at_a_time.

digest::digest2int("key_a")
#> [1] 1414969953