https://github.com/erich-9/shake.jl
SHAKE128 and SHAKE256 for Julia
https://github.com/erich-9/shake.jl
julia shake128 shake256
Last synced: 4 months ago
JSON representation
SHAKE128 and SHAKE256 for Julia
- Host: GitHub
- URL: https://github.com/erich-9/shake.jl
- Owner: erich-9
- License: mit
- Created: 2024-02-04T14:59:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-25T10:35:45.000Z (10 months ago)
- Last Synced: 2025-09-23T17:55:38.374Z (9 months ago)
- Topics: julia, shake128, shake256
- Language: Julia
- Homepage:
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SHAKE
[](https://github.com/erich-9/SHAKE.jl/actions/workflows/CI.yml?query=branch%3Amain)
[](https://codecov.io/gh/erich-9/SHAKE.jl)
[](https://github.com/JuliaTesting/Aqua.jl)
Implementation of the [extendable-output functions](https://en.wikipedia.org/wiki/Extendable-output_function) (XOF's) SHAKE128 and SHAKE256 based on the [SHA-3](https://en.wikipedia.org/wiki/SHA-3) implementation in the Julia Standard Library.
## Installation
Install with the Julia package manager [Pkg](https://pkgdocs.julialang.org/), just like any other registered Julia package:
```jl
pkg> add SHAKE # Press ']' to enter the Pkg REPL mode.
```
or
```jl
julia> using Pkg; Pkg.add("SHAKE")
```
## Usage
Loading the package will export `shake128_xof` and `shake256_xof` as well as `shake128` and `shake256` and finally also `SHAKE128RNG` and `SHAKE256RNG`:
```jl
using SHAKE
```
The methods `shake128_xof` and `shake256_xof` may be used as infinite iterators:
```jl
for (i, b) in enumerate(shake256_xof(b"Hash me!"))
if iszero(b)
println("Found first null byte at position $i")
break
end
end
```
The random byte generators `SHAKE128RNG` and `SHAKE256RNG` subtype `AbstractRNG` and can be used as follows:
```jl
rng = SHAKE128RNG(b"Hash me!")
some_random_bytes = rand(rng, UInt8, 47)
more_random_bytes = rand(rng, UInt8, 11)
```
For convenience, there also are `shake128` and `shake256`, which compute an output of a specified, fixed length:
```jl
shake128(b"Hash me!", 32)
```