Skip to content

Commit

Permalink
Minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkschumacher committed Sep 28, 2018
1 parent 7436834 commit 70f296c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions R/hash_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ hash_names <- function(..., size = 6, full = TRUE, salt = NULL) {


## hash it all
hash <- vapply(lab, hmac(salt), NA_character_)
hash <- vapply(lab, hash(salt), NA_character_)
hash_short <- substr(hash, 1, size)

if (full) {
Expand All @@ -76,12 +76,12 @@ hash_names <- function(..., size = 6, full = TRUE, salt = NULL) {
return(out)
}

hmac <- function(salt = NULL) {
hash <- function(salt = NULL) {
stopifnot(is.null(salt) || length(salt) == 1L)
if (!is.null(salt)) {
salt <- sodium::hash(charToRaw(as.character(salt)))
} else {
if (is.null(salt)) {
salt <- raw(32L)
} else {
salt <- sodium::hash(charToRaw(as.character(salt)))
}
function(x) {
stopifnot(is.character(x))
Expand Down

0 comments on commit 70f296c

Please sign in to comment.