{"id":16275527,"url":"https://github.com/shikokuchuo/secretbase","last_synced_at":"2026-01-08T14:17:32.963Z","repository":{"id":218137969,"uuid":"745691432","full_name":"shikokuchuo/secretbase","owner":"shikokuchuo","description":"secretbase - Cryptographic Hash and Extendable-Output Functions","archived":false,"fork":false,"pushed_at":"2024-05-15T16:15:34.000Z","size":921,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-17T03:45:17.001Z","etag":null,"topics":["cran","cryptographic-hash-functions","extendable-output-functions","keccak","r","r-package","rstats","sha256","sha3","shake256","siphash"],"latest_commit_sha":null,"homepage":"https://shikokuchuo.net/secretbase/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shikokuchuo.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-19T22:08:33.000Z","updated_at":"2024-05-30T00:53:59.443Z","dependencies_parsed_at":"2024-04-02T11:25:14.145Z","dependency_job_id":"67c7dc7d-d992-4669-af80-a5bc59f7f49e","html_url":"https://github.com/shikokuchuo/secretbase","commit_stats":null,"previous_names":["shikokuchuo/secretbase"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shikokuchuo%2Fsecretbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shikokuchuo%2Fsecretbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shikokuchuo%2Fsecretbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shikokuchuo%2Fsecretbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shikokuchuo","download_url":"https://codeload.github.com/shikokuchuo/secretbase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244033611,"owners_count":20386958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cran","cryptographic-hash-functions","extendable-output-functions","keccak","r","r-package","rstats","sha256","sha3","shake256","siphash"],"created_at":"2024-10-10T18:35:11.604Z","updated_at":"2026-01-08T14:17:32.958Z","avatar_url":"https://github.com/shikokuchuo.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r}\n#| include: false\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  out.width = \"100%\"\n)\n```\n\n# secretbase\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/secretbase?color=17411d)](https://CRAN.R-project.org/package=secretbase)\n[![secretbase status badge](https://shikokuchuo.r-universe.dev/badges/secretbase)](https://shikokuchuo.r-universe.dev/secretbase)\n[![R-CMD-check](https://github.com/shikokuchuo/secretbase/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/shikokuchuo/secretbase/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/shikokuchuo/secretbase/graph/badge.svg)](https://app.codecov.io/gh/shikokuchuo/secretbase)\n\u003c!-- badges: end --\u003e\n\n```\n  ________  \n /\\ sec   \\\n/  \\ ret   \\\n\\  /  base /\n \\/_______/\n```\n\nFast and memory-efficient streaming hash functions, binary encoding and serialization.\n\nHashes strings and raw vectors directly. Stream hashes files which can be larger than memory, as well as in-memory objects through R's serialization mechanism.\n\nImplements the SHA-256, SHA-3 and 'Keccak' cryptographic hash functions, SHAKE256 extendable-output function (XOF), 'SipHash' pseudo-random function, base64 and base58 encoding, and 'CBOR' serialization.\n\n| Function | Purpose |\n|----------|---------|\n| `sha3()` `sha256()` `keccak()` | Cryptographic hashes |\n| `shake256()` | Extendable-output function (XOF) |\n| `siphash13()` | Keyed, fast pseudo-random function |\n| `base64enc()` `base64dec()` | Base64 encoding |\n| `base58enc()` `base58dec()` | Base58 encoding with checksum |\n| `cborenc()` `cbordec()` | CBOR serialization |\n\n### Installation\n\n```{r}\n#| label: cran\n#| eval: false\ninstall.packages(\"secretbase\")\n```\n\n### Get Started\n\n```{r}\n#| label: secretbase\nlibrary(secretbase)\n```\n\n### Hash Functions\n\n#### SHA-3\n\nSpecify `bits` as `224`, `256`, `384` or `512`:\n```{r}\n#| label: sha3\nsha3(\"secret base\")\nsha3(\"secret base\", convert = FALSE)\nsha3(\"秘密の基地の中\", bits = 512L)\n```\n\n#### SHA-256\n\n```{r}\n#| label: sha256\nsha256(\"secret base\")\n```\nFor HMAC, pass a character string or raw vector to `key`:\n```{r}\n#| label: hmac\nsha256(\"secret base\", key = \"秘密の基地の中\")\n```\n\n#### Keccak\n\n```{r}\n#| label: keccak\nkeccak(\"secret base\", bits = 384L)\n```\n\n#### SHAKE256\n\nAn extendable-output function (XOF). Specify arbitrary `bits`. May be used as deterministic random seeds for R's pseudo random number generators (RNGs) - use `convert = NA` for integer output:\n```{r}\n#| label: shake256\nshake256(\"秘密の基地の中\", bits = 32L, convert = NA)\n```\nFor use in parallel computing, this is a valid method for reducing to a negligible probability that RNGs in each process may overlap. This may be especially suitable when first-best alternatives such as using recursive streams are too expensive or unable to preserve reproducibility. \u003csup\u003e[1]\u003c/sup\u003e\n\n#### SipHash\n\nSipHash-1-3 is a fast, keyed pseudo-random function. Pass to `key` up to 16 bytes (128 bits):\n```{r}\n#| label: siphash\nsiphash13(\"secret base\", key = \"秘密の基地の中\")\n```\n\n### Streaming\n\nAll hash functions above support streaming of R objects and files.\n\n#### R Objects\n\nCharacter strings and raw vectors are hashed directly. All other objects are stream hashed using R serialization:\n\n- memory-efficient as performed without allocation of the serialized object\n- portable as uses serialization version 3, big-endian representation, skipping headers\n\n```{r}\n#| label: streaming\nsha3(data.frame(a = 1, b = 2), bits = 224L)\nsha3(NULL)\n```\n\n#### Files\n\nFiles are read and hashed incrementally, accepting files larger than memory:\n```{r}\n#| label: files\nfile \u003c- tempfile(); cat(\"secret base\", file = file)\nsha3(file = file)\n```\n```{r}\n#| label: unlink\n#| echo: false\nunlink(file)\n```\n\n### Encoding\n\n#### Base64\n\n```{r}\n#| label: base64\nbase64enc(\"secret base\")\nbase64dec(base64enc(\"secret base\"))\nbase64enc(as.raw(c(1L, 2L, 4L)), convert = FALSE)\nbase64dec(base64enc(data.frame()), convert = NA)\n```\n\n#### Base58\n\nIncludes a 4-byte checksum (double SHA-256), verified on decode:\n```{r}\n#| label: base58\nbase58enc(\"secret base\")\nbase58dec(base58enc(\"secret base\"))\nbase58enc(as.raw(c(1L, 2L, 4L)), convert = FALSE)\nbase58dec(base58enc(data.frame()), convert = NA)\n```\n\n### Serialization\n\n#### CBOR\n\nEncode R objects to CBOR (RFC 8949) - a compact binary format. Supports integers, doubles, strings, raw vectors, logical, NULL, and lists (named lists become maps):\n```{r}\n#| label: cbor\ncborenc(list(a = 1L, b = \"hello\", c = TRUE))\ncbordec(cborenc(list(a = 1L, b = \"hello\", c = TRUE)))\n```\n\n### Implementation\n\nThe SHA-3 Secure Hash Standard was published by the National Institute of Standards and Technology (NIST) in 2015 at [doi:10.6028/NIST.FIPS.202](https://dx.doi.org/10.6028/NIST.FIPS.202). SHA-3 is based on the Keccak algorithm, designed by G. Bertoni, J. Daemen, M. Peeters and G. Van Assche.\n\nThe SHA-256 Secure Hash Standard was published by NIST in 2002 at \u003chttps://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf\u003e.\n\nThe SHA-256, SHA-3, Keccak, and base64 implementations are based on those by the 'Mbed TLS' Trusted Firmware Project at \u003chttps://www.trustedfirmware.org/projects/mbed-tls\u003e.\n\nThe SipHash family of pseudo-random functions by Jean-Philippe Aumasson and Daniel J. Bernstein was published in 2012 at \u003chttps://ia.cr/2012/351\u003e. \u003csup\u003e[2]\u003c/sup\u003e\n\nThe SipHash implementation is based on that of Daniele Nicolodi, David Rheinsberg and Tom Gundersen at \u003chttps://github.com/c-util/c-siphash\u003e, which is in turn based on the reference implementation by Jean-Philippe Aumasson and Daniel J. Bernstein released to the public domain at \u003chttps://github.com/veorq/SipHash\u003e.\n\nThe base58 implementation is based on 'libbase58' by Luke Dashjr at \u003chttps://github.com/luke-jr/libbase58\u003e.\n\nThe CBOR implementation follows RFC 8949, *\"Concise Binary Object Representation (CBOR)\"*, available at \u003chttps://www.rfc-editor.org/rfc/rfc8949\u003e.\n\n### References\n\n[1] Pierre L’Ecuyer, David Munger, Boris Oreshkin and Richard Simard (2017), *\"Random numbers for parallel computers: Requirements and methods, with emphasis on GPUs\"*, Mathematics and Computers in Simulation, Vol. 135, May 2017, pp. 3-17 [doi:10.1016/j.matcom.2016.05.00](https://doi.org/10.1016/j.matcom.2016.05.005).\n\n[2] Jean-Philippe Aumasson and Daniel J. Bernstein (2012), *\"SipHash: a fast short-input PRF\"*, Paper 2012/351, Cryptology ePrint Archive, \u003chttps://ia.cr/2012/351\u003e.\n\n### Links\n\n◈ secretbase R package: \u003chttps://shikokuchuo.net/secretbase/\u003e\n\nMbed TLS website: \u003chttps://www.trustedfirmware.org/projects/mbed-tls\u003e\u003cbr /\u003e\nSipHash streaming implementation: \u003chttps://github.com/c-util/c-siphash\u003e\u003cbr /\u003e\nSipHash reference implementation: \u003chttps://github.com/veorq/SipHash\u003e\u003cbr /\u003e\nlibbase58: \u003chttps://github.com/luke-jr/libbase58\u003e\u003cbr /\u003e\nCBOR RFC 8949: \u003chttps://www.rfc-editor.org/rfc/rfc8949\u003e\n\n--\n\nPlease note that this project is released with a [Contributor Code of Conduct](https://shikokuchuo.net/secretbase/CODE_OF_CONDUCT.html). By participating in this project you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshikokuchuo%2Fsecretbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshikokuchuo%2Fsecretbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshikokuchuo%2Fsecretbase/lists"}