Generates hashes with or without an extra key/salt. This key defaults to the project identifier.

generate_hash(x, key = TRUE, bits = 256)

Arguments

x

input, will be converted to character

key

key or salt. Use TRUE (default) to use the project identifier that will be printed to the Console, or any character to use as key/salt, or use NULL or FALSE to not use a key.

bits

number of bits, often one of: 224, 256, 384, 512

Details

This function uses the openssl::sha2() function for the hashing, but always returns a character vector.

Examples

generate_hash("a")
#> Using {certeprojects} project identifier as hash key: "runner-2507111346".
#> [1] "aa7e897cddbc997db2a4f8f3d80f55b928b017618e1c7849e080d996028cd524"
generate_hash(c("a", "b", "c"))
#> Using {certeprojects} project identifier as hash key: "runner-2507111346".
#> [1] "aa7e897cddbc997db2a4f8f3d80f55b928b017618e1c7849e080d996028cd524"
#> [2] "0d21038b750b7513c837ca55340e9e4134ee360950610d6e277b6910659f30d0"
#> [3] "d9442845600110ab6b7add81132e710861dd8bc3e5c13b80ba9c68d2a0caa8b4"

generate_hash("a", "secret")
#> [1] "4048c44911916043ff626895ff78c5262764685b6cb9a03ce07886a9effb924c"
generate_hash(c("a", "b", "c"), "secret")
#> [1] "4048c44911916043ff626895ff78c5262764685b6cb9a03ce07886a9effb924c"
#> [2] "8caf295837e09c876c0c5ef729581d5e75ef93adc10420ce71aab05636ac63ed"
#> [3] "ef006b65b8ce49c891479554278e47e7d76735e7ddd6392fc68342322f39e3c4"