Browse Source

turned errors into warnings with NA return

master
boB Rudis 6 years ago
parent
commit
d03a8ae05e
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 12
      R/tlsh-hash.R
  2. 2
      man/tlsh_simple_hash.Rd

12
R/tlsh-hash.R

@ -1,15 +1,23 @@
#' Compute TLSH hash for a character or raw vector and return hash fingerprint
#'
#' A warning will be issued if the input byte stream is <50 bytes.
#'
#' @md
#' @param x length 1 `character` or `raw` vector
#' @export
tlsh_simple_hash <- function(x) {
if (inherits(x, "character")) {
x <- x[1]
if (nchar(x) < 50L) stop("Byte stream minimum length is 50 bytes", call.=FALSE)
if (nchar(x) < 50L) {
warning("Byte stream minimum length is 50 bytes.")
return(NA_character_)
}
tlsh_simple_hash_c(x)
} else if (inherits(x, "raw")) {
if (length(x) < 50L) stop("Byte stream minimum length is 50 bytes", call.=FALSE)
if (length(x) < 50L) {
warning("Byte stream minimum length is 50 bytes.")
return(NA_character_)
}
tlsh_simple_hash_r(x)
} else {
NULL

2
man/tlsh_simple_hash.Rd

@ -10,5 +10,5 @@ tlsh_simple_hash(x)
\item{x}{length 1 \code{character} or \code{raw} vector}
}
\description{
Compute TLSH hash for a character or raw vector and return hash fingerprint
A warning will be issued if the input byte stream is <50 bytes.
}

Loading…
Cancel
Save