Skip to content

Accept raw chectors as well as characters #3

@noamross

Description

@noamross

Hi there! I was wondering if you would be able to make functions in this package accept raw vectors as well as characters.

This is because sometimes raw vectors can not be converted to characters because they contain NUL (00), causing rawToChar to error out.

My application is checking web pages against archives in the Wayback machine, which fingerprints web pages as base32-encoded SHA1s of webpage contents. It's the SHA1 that sometimes has 00 values in it.

So this will fail for some URLs:

content <- readBin(url("https://example.com", open = "rb"), "raw", n=10000)

  content |> 
    digest::digest(algo = "sha1", serialize = FALSE, raw = TRUE) |> 
    rawToChar() |>
    base64url::base32_encode()

(Returning the SHA1 as a character does not help, as digest is ju

This is the only R base32 encoder I can find. base64s are a dime a dozen :) Thanks for it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions