raw2hex: Convert raw vector to string hex representation

Description Usage Arguments Details Value Author(s) Examples

View source: R/tools.R

Description

raw2hex convers a raw vector into hexadecimal representation

Usage

1
raw2hex(what, sep, upper = FALSE)

Arguments

what

raw vector

sep

optional separator string

upper

logical, if TRUE then upper case letters are used, otherwise any letters will be lower case.

Details

If sep is omitted or NULL then the resulting character vector will have as many elements as the raw vector. Otherwise the elements are concatenated using the specified separator into one character string. This is much more efficient than using paste(raw2hex(x), collapse=sep), but has the same effect.

Value

Character vector with the hexadecimal representation of the raw vector.

Author(s)

Simon Urbanek

Examples

1
2
3
4
5
6
7
8
9
raw2hex(PKI.digest(raw(), "SHA1"), "")
raw2hex(PKI.digest(raw(), "MD5"), ":")

## this is jsut a performance comparison and a test that
## raw2hex can handle long strings
x <- as.raw(runif(1e5) * 255.9)
system.time(h1 <- raw2hex(x, " "))
system.time(h2 <- paste(raw2hex(x), collapse=" "))
stopifnot(identical(h1, h2))

PKI documentation built on May 19, 2017, 7:49 a.m.

Search within the PKI package
Search all R packages, documentation and source code