https://github.com/ya2ir/sha1
SHA-1 in Golang
https://github.com/ya2ir/sha1
cryptography hashing-algorithm hashing-algorithms sha-1 sha-1-hash
Last synced: 14 days ago
JSON representation
SHA-1 in Golang
- Host: GitHub
- URL: https://github.com/ya2ir/sha1
- Owner: YA2IR
- License: mit
- Created: 2025-02-11T13:19:30.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-11T14:00:54.000Z (8 months ago)
- Last Synced: 2025-08-09T21:48:46.727Z (2 months ago)
- Topics: cryptography, hashing-algorithm, hashing-algorithms, sha-1, sha-1-hash
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SHA1 Implementation in Go
This is an implementation of [SHA-1](https://en.wikipedia.org/wiki/SHA-1) in Go. It follows the [FIPS 180-1](https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub180-1.pdf) standard.## Features
- Interactive REPL for experimentation (see [As a REPL](#as-a-repl))
## Limitations
- This implementation is strictly for educational purposes. SHA-1 is considered cryptographically broken and should **not** be used in production.
## Usage### As a Library
```go
package mainimport (
"fmt"
"github.com/YA2IR/sha1"
)func main() {
s := sha1.NewSHA1()message1 := "hello world"
message2 := "hello"digest := s.Hash([]byte(message1))
fmt.Printf("SHA1 of \"%s\" = %x\n", message1, digest)digest = s.Hash([]byte(message2))
fmt.Printf("SHA1 of \"%s\" = %x\n", message2, digest)}
```
output:
```
SHA1 of "hello world" = 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
SHA1 of "hello" = aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
```
### As a REPL
Clone this repo:
```bash
git clone https://github.com/YA2IR/sha1.git
cd sha1
```
Then you can run:
```bash
go run cmd/sha1/main.go
```
```
Welcome to SHA1 REPL, write 'exit' to exit
> test
SHA1: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
> test2
SHA1: 109f4b3c50d7b0df729d299bc6f8e9ef9066971f
> exit```