From 70f296c661ed89f5ba47c460bf20d1e6f10423d9 Mon Sep 17 00:00:00 2001 From: Dirk Schumacher Date: Fri, 28 Sep 2018 18:40:33 +0200 Subject: [PATCH] Minor code improvements --- R/hash_names.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/hash_names.R b/R/hash_names.R index c12b96f..49c2f80 100644 --- a/R/hash_names.R +++ b/R/hash_names.R @@ -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) { @@ -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))