https://github.com/sanjay-sol/sha256-implementation
SHA256 Implementation written in Go.
https://github.com/sanjay-sol/sha256-implementation
go hash-functions sha-256
Last synced: 3 months ago
JSON representation
SHA256 Implementation written in Go.
- Host: GitHub
- URL: https://github.com/sanjay-sol/sha256-implementation
- Owner: sanjay-sol
- Created: 2024-10-18T18:21:06.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-10-20T16:57:27.000Z (12 months ago)
- Last Synced: 2025-05-15T19:44:39.412Z (5 months ago)
- Topics: go, hash-functions, sha-256
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SHA-256 Implementation in Go
Reference Paper : [The cryptographic hash function SHA-256](https://helix.stormhub.org/papers/SHA-256.pdf)
## Overview
SHA-256 (Secure Hash Algorithm 256) is a cryptographic hash function that produces a 256-bit (32-byte) hash value for any input.
## How It Works
The implementation follows the SHA-256 algorithm, which consists of the following main steps:
1. **Input Preprocessing**: Convert the input message into a bit representation and apply necessary padding.
2. **Block Processing**: Divide the padded message into 512-bit blocks.
3. **Hash Computation**: For each block, compute the hash using a series of logical operations and constants.
4. **Output the Final Hash**: Combine the computed hash values into a final output.### Key SHA-256 Functions
- **`rotr(x uint32, n uint) uint32`**: Right rotates a 32-bit integer.
- **`sigma0(x uint32) uint32`**: Auxiliary function for SHA-256.
- **`sigma1(x uint32) uint32`**: Auxiliary function for SHA-256.
- **`summation0(x uint32) uint32`**: Auxiliary function for SHA-256.
- **`summation1(x uint32) uint32`**: Auxiliary function for SHA-256.
- **`ch(x, y, z uint32) uint32`**: Choice function for SHA-256.
- **`maj(x, y, z uint32) uint32`**: Majority function for SHA-256.
- **`generateMessageSchedule(block []uint32) []uint32`**: Generates the message schedule for the current block.