Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Jan 20, 2024
1 parent 76a6ca1 commit b8475c4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
6 changes: 3 additions & 3 deletions R/base.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
#' character string hex representation if 'convert' is TRUE, or returned as
#' a raw vector if 'convert' is FALSE.
#'
#' To hash to an integer value (for example to supply as a random seed to
#' R's pseudo RNGs), set 'size' to 32 and 'convert' to FALSE, and pass the
#' resulting raw vector to \code{\link{read_integer}}.
#' To hash to an integer value, set 'size' to 32 and 'convert' to FALSE, and
#' pass the resulting raw vector to \code{\link{read_integer}}. This may be
#' used to generate random seeds for R's pseudo RNGs.
#'
#' @examples
#' # SHA3-256 hash as character string:
Expand Down
19 changes: 12 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ install.packages("secretbase", repos = "https://shikokuchuo.r-universe.dev")

`secretbase` offers one main function `sha3()`:

To use the SHA-3 cryptographic hash algorithm, specify argument 'size' as one of '224', '256', '384' or '512'.

Specify an arbitrary output size to use the SHAKE256 algorithm as an extendable-output function (XOF).
To use:

- SHA-3 cryptographic hash algorithm, specify 'size' as one of '224', '256', '384' or '512'.
- SHAKE256 extendable-output function (XOF), specify any other arbitrary output size.

```{r secretbase}
library(secretbase)
Expand All @@ -57,20 +58,24 @@ sha3("secret base")
sha3("secret base", convert = FALSE)
sha3("秘密の基地", size = 224)
sha3("秘密の基地の中", size = 224)
sha3("秘密の基地", size = 512)
sha3("秘密の基地の中", size = 512)
```

To hash to an integer value (for example to generate random seeds for R's pseudo RNGs), specify a size of '32' and pass the resulting raw vector to `read_integer()`.
To:

- hash to an integer value, specify a size of '32' and pass the resulting raw vector to `read_integer()`.

```{r readinteger}
hash <- sha3("秘密の基地", size = 32, convert = FALSE)
hash <- sha3("秘密の基地の中", size = 32, convert = FALSE)
hash
read_integer(hash)
```

This may be used to generate random seeds for R's pseudo RNGs.

### Links

Links:
Expand Down
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ install.packages("secretbase", repos = "https://shikokuchuo.r-universe.dev")

`secretbase` offers one main function `sha3()`:

To use the SHA-3 cryptographic hash algorithm, specify argument ‘size’
as one of ‘224’, ‘256’, ‘384’ or ‘512’.
To use:

Specify an arbitrary output size to use the SHAKE256 algorithm as an
extendable-output function (XOF).
- SHA-3 cryptographic hash algorithm, specify ‘size’ as one of ‘224’,
‘256’, ‘384’ or ‘512’.
- SHAKE256 extendable-output function (XOF), specify any other arbitrary
output size.

``` r
library(secretbase)
Expand All @@ -56,26 +57,29 @@ sha3("secret base", convert = FALSE)
#> [1] a7 21 d5 75 70 e7 ce 36 6a de e2 fc cb e9 77 07 23 c6 e3 62 25 49 c3 1c 7c
#> [26] ab 9d bb 4a 79 55 20

sha3("秘密の基地", size = 224)
#> [1] "df2b0bc4d37831d1ec6624312be9ab75e22e08eca52d059d184edf39"
sha3("秘密の基地の中", size = 224)
#> [1] "d9e291d0c9f3dc3007dc0c111aea0b6a938929c8b4766332d8ea791a"

sha3("秘密の基地", size = 512)
#> [1] "d9553a1e8d9ea1cf9d053f72c499d040a11724f32be6e568aba6b078950ae2679842806450bd62f97da8eca517a68c0aa386349140724968daceeac2eaa1340a"
sha3("秘密の基地の中", size = 512)
#> [1] "e30cdc73f6575c40d55b5edc8eb4f97940f5ca491640b41612e02a05f3e59dd9c6c33f601d8d7a8e2ca0504b8c22f7bc69fa8f10d7c01aab392781ff4ae1e610"
```

To hash to an integer value (for example to generate random seeds for
R’s pseudo RNGs), specify a size of ‘32’ and pass the resulting raw
vector to `read_integer()`.
To:

- hash to an integer value, specify a size of ‘32’ and pass the
resulting raw vector to `read_integer()`.

``` r
hash <- sha3("秘密の基地", size = 32, convert = FALSE)
hash <- sha3("秘密の基地の中", size = 32, convert = FALSE)
hash
#> [1] 6a 92 94 19
#> [1] 7f c2 38 77

read_integer(hash)
#> [1] 429167210
#> [1] 2000208511
```

This may be used to generate random seeds for R’s pseudo RNGs.

### Links

Links:
Expand Down
6 changes: 3 additions & 3 deletions man/sha3.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b8475c4

Please sign in to comment.