Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

sil-28/SHA3

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
1 Commit
 
 
 
 

Repository files navigation

SHA-3 / Keccak — Java Implementation

A from-scratch implementation of the SHA-3 hash function family in Java, following the FIPS 202 standard.

Overview

SHA-3 is based on the Keccak sponge construction, which applies a permutation function (Keccak-p) to absorb the input and squeeze out the digest. This implementation covers all four standardized variants:

Variant Digest size Capacity
SHA3-224 224 bits 448 bits
SHA3-256 256 bits 512 bits
SHA3-384 384 bits 768 bits
SHA3-512 512 bits 1024 bits

Structure

The Keccak-p permutation is built from five step mappings applied each round:

  • θ (Theta) — XORs each bit with the parity of two columns
  • ρ (Rho) — rotates each lane by a fixed offset
  • π (Pi) — rearranges the positions of the lanes
  • χ (Chi) — applies a non-linear function to each row
  • ι (Iota) — XORs lane (0,0) with a round constant

Usage

Compile and run

javac Sha3.java && java -cp . Sha3

API

All methods take and return binary strings (sequences of '0' and '1'). Use the provided HexToBin and BinToHex helpers to convert to/from hex.

String input = Sha3.HexToBin("A3A3A3...");
String digest = Sha3.BinToHex(Sha3.SHA3_256(input));

Test Vectors

The test() method verifies the implementation against the official NIST test vectors from FIPS 202, including:

  • Empty input
  • 1600-bit input (A3 repeated 200 times)

Run the main class to execute all tests. Expected output is true for each variant.

Reference

About

From-scratch implementation of SHA-3 (Keccak) hash function family in Java, following FIPS 202

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.