Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ventaquil committed Dec 21, 2023
0 parents commit 4e80301
Show file tree
Hide file tree
Showing 13 changed files with 2,425 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .cargo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# chksum-hash-sha2-384

[![GitHub](https://img.shields.io/badge/github-chksum--rs%2Fhash--sha2--384-24292e?style=flat-square&logo=github "GitHub")](https://github.com/chksum-rs/hash-sha2-384)
[![Build](https://img.shields.io/github/actions/workflow/status/chksum-rs/hash-sha2-384/rust.yml?branch=master&style=flat-square&logo=github "Build")](https://github.com/chksum-rs/hash-sha2-384/actions/workflows/rust.yml)
[![docs.rs](https://img.shields.io/docsrs/chksum-hash-sha2-384?style=flat-square&logo=docsdotrs "docs.rs")](https://docs.rs/chksum-hash-sha2-384/)
[![MSRV](https://img.shields.io/badge/MSRV-1.63.0-informational?style=flat-square "MSRV")](https://github.com/chksum-rs/hash-sha2-384/blob/master/Cargo.toml)
[![deps.rs](https://deps.rs/crate/chksum-hash-sha2-384/0.0.0/status.svg?style=flat-square "deps.rs")](https://deps.rs/crate/chksum-hash-sha2-384/0.0.0)
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg?style=flat-square "unsafe forbidden")](https://github.com/rust-secure-code/safety-dance)
[![LICENSE](https://img.shields.io/github/license/chksum-rs/hash-sha2-384?style=flat-square "LICENSE")](https://github.com/chksum-rs/hash-sha2-384/blob/master/LICENSE)

An implementation of SHA-2 384 hash algorithm for batch and stream computation.

## Setup

To use this crate, add the following entry to your `Cargo.toml` file in the `dependencies` section:

```toml
[dependencies]
chksum-hash-sha2-384 = "0.0.0"
```

Alternatively, you can use the [`cargo add`](https://doc.rust-lang.org/cargo/commands/cargo-add.html) subcommand:

```shell
cargo add chksum-hash-sha2-384
```

## Usage

Use the `hash` function for batch digest calculation.

```rust
use chksum_hash_sha2_384 as sha2_384;

let digest = sha2_384::hash(b"example data");
assert_eq!(
digest.to_hex_lowercase(),
"12ecdfd463a85a301b7c29a43bf4b19cdfc6e5e86a5f40396aa6ae3368a7e5b0ed31f3bef2eb3071577ba610b4ed1cb8"
);
```

Use the `default` function to create a hash instance for stream digest calculation.

```rust
use chksum_hash_sha2_384 as sha2_384;

let digest = sha2_384::default()
.update("example")
.update(b"data")
.update([0, 1, 2, 3])
.digest();
assert_eq!(
digest.to_hex_lowercase(),
"ef0484e7424aa96c8f3d4910ac081d129b089435e4275b0cec9327a09959359e18c3ca55355fbc32968d20c85c379d86"
);
```

For more usage examples, refer to the documentation available at [docs.rs](https://docs.rs/chksum-hash-sha2-384/).

## License

This crate is licensed under the MIT License.
141 changes: 141 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Rust

env:
CARGO_TERM_COLOR: always

permissions:
contents: read

on:
push:
branches:
- master
paths:
- ".github/workflows/*.yml"
- "Cargo.toml"
- "src/**.rs"
- "tests/**.rs"
pull_request:
branches:
- master
paths:
- ".github/workflows/*.yml"
- "Cargo.toml"
- "src/**.rs"
- "tests/**.rs"

jobs:
lint:
runs-on: ubuntu-latest
name: Lint
permissions:
checks: write
contents: write
pull-requests: write
steps:
- name: Repository checkout
uses: actions/checkout@v3
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true
profile: minimal
components: rustfmt, clippy
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --check --verbose
- name: Run cargo clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features -- --deny clippy::cargo

build-and-test-linux:
needs:
- lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [1.63.0, stable, nightly]
name: "Build and test (OS: Linux, Toolchain: ${{ matrix.toolchain }})"
steps:
- name: Repository checkout
uses: actions/checkout@v3
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
default: true
profile: minimal
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --verbose
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --verbose

build-and-test-macos:
needs:
- lint
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
toolchain: [1.63.0, stable, nightly]
name: "Build and test (OS: MacOS, Toolchain: ${{ matrix.toolchain }})"
steps:
- name: Repository checkout
uses: actions/checkout@v3
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
default: true
profile: minimal
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --verbose
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --verbose

build-and-test-windows:
needs:
- lint
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
toolchain: [1.63.0, stable, nightly]
name: "Build and test (OS: Windows, Toolchain: ${{ matrix.toolchain }})"
steps:
- name: Repository checkout
uses: actions/checkout@v3
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
default: true
profile: minimal
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --verbose
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --verbose
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Cargo
Cargo.lock
target/
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.0] - 2023-12-21

### Added

- Initial release.

[0.0.0]: https://github.com/chksum-rs/hash-sha2-384/releases/tag/v0.0.0
20 changes: 20 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "chksum-hash-sha2-384"
version = "0.0.0"
authors = ["Konrad Goławski <konrad@golawski.it>"]
edition = "2021"
rust-version = "1.63.0"
description = "An implementation of SHA-2 384 hash algorithm for batch and stream computation."
readme = ".cargo/README.md"
repository = "https://github.com/chksum-rs/hash-sha2-384"
license = "MIT"
keywords = ["checksum", "digest", "hash", "sha384", "sha2-384"]
categories = ["algorithms", "cryptography"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
chksum-hash-core = "0.0.0"
thiserror = "1.0.51"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Konrad Goławski

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# chksum-hash-sha2-384

[![crates.io](https://img.shields.io/crates/v/chksum-hash-sha2-384?style=flat-square&logo=rust "crates.io")](https://crates.io/crates/chksum-hash-sha2-384)
[![Build](https://img.shields.io/github/actions/workflow/status/chksum-rs/hash-sha2-384/rust.yml?branch=master&style=flat-square&logo=github "Build")](https://github.com/chksum-rs/hash-sha2-384/actions/workflows/rust.yml)
[![docs.rs](https://img.shields.io/docsrs/chksum-hash-sha2-384?style=flat-square&logo=docsdotrs "docs.rs")](https://docs.rs/chksum-hash-sha2-384/)
[![MSRV](https://img.shields.io/badge/MSRV-1.63.0-informational?style=flat-square "MSRV")](https://github.com/chksum-rs/hash-sha2-384/blob/master/Cargo.toml)
[![deps.rs](https://deps.rs/crate/chksum-hash-sha2-384/0.0.0/status.svg?style=flat-square "deps.rs")](https://deps.rs/crate/chksum-hash-sha2-384/0.0.0)
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg?style=flat-square "unsafe forbidden")](https://github.com/rust-secure-code/safety-dance)
[![LICENSE](https://img.shields.io/github/license/chksum-rs/hash-sha2-384?style=flat-square "LICENSE")](https://github.com/chksum-rs/hash-sha2-384/blob/master/LICENSE)

An implementation of SHA-2 384 hash algorithm for batch and stream computation.

## Setup

To use this crate, add the following entry to your `Cargo.toml` file in the `dependencies` section:

```toml
[dependencies]
chksum-hash-sha2-384 = "0.0.0"
```

Alternatively, you can use the [`cargo add`](https://doc.rust-lang.org/cargo/commands/cargo-add.html) subcommand:

```shell
cargo add chksum-hash-sha2-384
```

## Usage

Use the `hash` function for batch digest calculation.

```rust
use chksum_hash_sha2_384 as sha2_384;

let digest = sha2_384::hash(b"example data");
assert_eq!(
digest.to_hex_lowercase(),
"12ecdfd463a85a301b7c29a43bf4b19cdfc6e5e86a5f40396aa6ae3368a7e5b0ed31f3bef2eb3071577ba610b4ed1cb8"
);
```

Use the `default` function to create a hash instance for stream digest calculation.

```rust
use chksum_hash_sha2_384 as sha2_384;

let digest = sha2_384::default()
.update("example")
.update(b"data")
.update([0, 1, 2, 3])
.digest();
assert_eq!(
digest.to_hex_lowercase(),
"ef0484e7424aa96c8f3d4910ac081d129b089435e4275b0cec9327a09959359e18c3ca55355fbc32968d20c85c379d86"
);
```

For more usage examples, refer to the documentation available at [docs.rs](https://docs.rs/chksum-hash-sha2-384).

## License

This crate is licensed under the MIT License.
17 changes: 17 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
combine_control_expr = false
edition = "2021"
force_multiline_blocks = true
format_code_in_doc_comments = true
format_generated_files = true
format_strings = true
group_imports = "StdExternalCrate"
hex_literal_case = "Upper"
imports_granularity = "Module"
imports_layout = "HorizontalVertical"
match_block_trailing_comma = true
max_width = 120
normalize_comments = true
normalize_doc_attributes = true
reorder_impl_items = true
use_field_init_shorthand = true
use_try_shorthand = true
Loading

0 comments on commit 4e80301

Please sign in to comment.