Skip to content

Commit

Permalink
catch one
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Jan 20, 2024
1 parent b733523 commit 76a6ca1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ knitr::opts_chunk$set(
[![CRAN status](https://www.r-pkg.org/badges/version/secretbase?color=42147b)](https://CRAN.R-project.org/package=secretbase)
[![secretbase status badge](https://shikokuchuo.r-universe.dev/badges/secretbase?color=e4723a)](https://shikokuchuo.r-universe.dev/secretbase)
[![R-CMD-check](https://github.com/shikokuchuo/secretbase/workflows/R-CMD-check/badge.svg)](https://github.com/shikokuchuo/secretbase/actions)
[![codecov](https://codecov.io/gh/shikokuchuo/secretbase/graph/badge.svg)](https://codecov.io/gh/shikokuchuo/secretbase)
[![codecov](https://codecov.io/gh/shikokuchuo/secretbase/graph/badge.svg)](https://app.codecov.io/gh/shikokuchuo/secretbase)
<!-- badges: end -->

Fast, dependency-free SHA-3 cryptographic hash and SHAKE256 extendable-output function (XOF) algorithms.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ status](https://www.r-pkg.org/badges/version/secretbase?color=42147b)](https://C
[![secretbase status
badge](https://shikokuchuo.r-universe.dev/badges/secretbase?color=e4723a)](https://shikokuchuo.r-universe.dev/secretbase)
[![R-CMD-check](https://github.com/shikokuchuo/secretbase/workflows/R-CMD-check/badge.svg)](https://github.com/shikokuchuo/secretbase/actions)
[![codecov](https://codecov.io/gh/shikokuchuo/secretbase/graph/badge.svg)](https://codecov.io/gh/shikokuchuo/secretbase)
[![codecov](https://codecov.io/gh/shikokuchuo/secretbase/graph/badge.svg)](https://app.codecov.io/gh/shikokuchuo/secretbase)
<!-- badges: end -->

Fast, dependency-free SHA-3 cryptographic hash and SHAKE256
Expand Down
2 changes: 1 addition & 1 deletion src/secret.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ SEXP secretbase_sha3(SEXP x, SEXP size, SEXP convert) {

secretbase_context sctx;
sctx.ctx = &ctx;
sctx.skip = SB_SERIAL_HEADER_ITEMS;
sctx.skip = SB_SERIAL_HEADERS;

struct R_outpstream_st output_stream;
R_InitOutPStream(
Expand Down
2 changes: 1 addition & 1 deletion src/secret.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <R_ext/Visibility.h>

#define SB_R_SERIAL_VER 3
#define SB_SERIAL_HEADER_ITEMS 5
#define SB_SERIAL_HEADERS 6
#define READ_INTEGER(x) (int *) DATAPTR_RO(x)

typedef enum {
Expand Down
9 changes: 5 additions & 4 deletions tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ test_equal(sha3("", 512), "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1d
test_equal(sha3("secret base", size = 32), "995ebac1")
test_equal(sha3(sha3("secret base", size = 32, convert = FALSE), size = 32), "4d872090")
test_that(sha3(rnorm(1e5), size = 8196), is.character)
test_equal(sha3(data.frame(a = 1, b = 2)), "33c6b16451e62e56ccab41cbb589178f199f2438b61ac758b707b7b1cd33d194")
test_equal(sha3(c("secret", "base")), "57bd267111cc85e1c773b0f199b5ea39aae1202f9414e7c320700fd7ad629707")
test_equal(sha3(NULL), "a15515f0723b692bbe28da9876d858c6cbdf75b19f55393512e72bf1d9c8c86e")
test_equal(sha3(substitute()), "503e9539989f8b17f7db440849d829d6d5ec0512cb501072156b1185cf297a9b")
test_equal(sha3(data.frame(a = 1, b = 2)), "05d4308e79d029b4af5604739ecc6c4efa1f602a23add0ed2d247b7407d4832f")
test_equal(sha3(c("secret", "base")), "d906024c71828a10e28865a80f5e81d2cb5cd74067d44852d7039813ba62b0b6")
test_equal(sha3(NULL), "b3e37e4c5def1bfb2841b79ef8503b83d1fed46836b5b913d7c16de92966dcee")
test_equal(sha3(substitute()), "9d31eb41cfb721b8040c52d574df1aacfc381d371c2b933f90792beba5160a57")
test_error(sha3("secret base", size = 0), "'size' must be between 8 and 2^24")
test_error(sha3("secret base", size = -1), "'size' must be between 8 and 2^24")
test_error(sha3("secret base", size = 2^24 + 1), "'size' must be between 8 and 2^24")
test_equal(read_integer(sha3("secret base", size = 32, convert = FALSE)), -1044750695L)
test_equal(read_integer(2:4), 2L)
test_that(read_integer(NULL), is.integer)
Expand Down

0 comments on commit 76a6ca1

Please sign in to comment.