Skip to content

erich-9/SHAKE.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SHAKE

Build Status Coverage Aqua

Implementation of the extendable-output functions (XOF's) SHAKE128 and SHAKE256 based on the SHA-3 implementation in the Julia Standard Library.

Installation

Install with the Julia package manager Pkg, just like any other registered Julia package:

pkg> add SHAKE  # Press ']' to enter the Pkg REPL mode.

or

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:

using SHAKE

The methods shake128_xof and shake256_xof may be used as infinite iterators:

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:

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:

shake128(b"Hash me!", 32)