Sha1
sha1.h is a pure C implementation of the SHA-1 hashing algorithm. It offers both a simple function interface (SHA1()) and a SHA1_CTX structure for processing multiple data chunks. Ideal for cryptographic and security applications.
Install / Use
/learn @halloweeks/Sha1README
SHA-1 Implementation in C
This is a simple implementation of the SHA-1 hashing algorithm in pure C language.
Introduction
The Secure Hash Algorithm 1 (SHA-1) is a cryptographic hash function that produces a 160-bit (20-byte) hash value known as a message digest, typically rendered as a hexadecimal number, 40 digits long. It was designed by the National Security Agency (NSA) and published by the National Institute of Standards and Technology (NIST) as a U.S. Federal Information Processing Standard.
Features
- Implemented in pure C language.
- Supports hashing of data from memory buffers.
- Follows the SHA-1 specification as outlined in FIPS PUB 180-1.
- Provides both a simple function interface (
SHA1()) and aSHA1_CTXstructure for processing multiple chunks of data.
Usage
Using the SHA1() Function
#include "sha1.h"
int main() {
unsigned char data[] = "Hello, World!";
unsigned char hash[SHA1_BLOCK_SIZE];
SHA1(data, sizeof(data) - 1, hash);
// Print or use the hash as needed
return 0;
}
Using the SHA1_CTX Structure
#include "sha1.h"
int main() {
unsigned char data1[] = "Hello, ";
unsigned char data2[] = "World!";
unsigned char hash[SHA1_BLOCK_SIZE];
SHA1_CTX ctx;
SHA1_Init(&ctx);
SHA1_Update(&ctx, data1, sizeof(data1) - 1);
SHA1_Update(&ctx, data2, sizeof(data2) - 1);
SHA1_Final(&ctx, hash);
// Print or use the hash as needed
return 0;
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
