boB Rudis
4 years ago
4 changed files with 59 additions and 4 deletions
@ -0,0 +1,28 @@ |
|||
#' Splits an ssdeep hash string into component parts |
|||
#' |
|||
#' ssdeep hashes consists of three parts, separated by `:`: |
|||
#' - chunk size : size of the chunks in rest of the hash |
|||
#' - chunk : where each character represents a part of the file of length "chunk size" |
|||
#' - double chunk : hash computation where "chunk size" = 2 * "chunk size" |
|||
#' This function splits the single has string into three component parts. |
|||
#' |
|||
#' @param x character vector of ssdeep hashes |
|||
#' @return data frame |
|||
#' @export |
|||
#' @examples |
|||
#' split_hash(hash_con(url("https://en.wikipedia.org/wiki/Donald_Knuth"))) |
|||
split_hash <- function(x) { |
|||
|
|||
components <- strsplit(x, ":", fixed = TRUE) |
|||
lapply(components, function(.x) { |
|||
as.data.frame(as.list(setNames(.x, c("chunk_size", "chunk", "double_chunk"))), stringsAsFactors = FALSE) |
|||
}) -> out |
|||
|
|||
out <- do.call(rbind.data.frame, out) |
|||
class(out) <- c("tbl_df", "tbl", "data.frame") |
|||
|
|||
out[["chunk_size"]] <- as.integer(out[["chunk_size"]]) |
|||
|
|||
out |
|||
|
|||
} |
@ -0,0 +1,26 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/split-hash.R |
|||
\name{split_hash} |
|||
\alias{split_hash} |
|||
\title{Splits an ssdeep hash string into component parts} |
|||
\usage{ |
|||
split_hash(x) |
|||
} |
|||
\arguments{ |
|||
\item{x}{character vector of ssdeep hashes} |
|||
} |
|||
\value{ |
|||
data frame |
|||
} |
|||
\description{ |
|||
ssdeep hashes consists of three parts, separated by \code{:}: |
|||
\itemize{ |
|||
\item chunk size : size of the chunks in rest of the hash |
|||
\item chunk : where each character represents a part of the file of length "chunk size" |
|||
\item double chunk : hash computation where "chunk size" = 2 * "chunk size" |
|||
This function splits the single has string into three component parts. |
|||
} |
|||
} |
|||
\examples{ |
|||
split_hash(hash_con(url("https://en.wikipedia.org/wiki/Donald_Knuth"))) |
|||
} |
Loading…
Reference in new issue