Skip to content

Commit

Permalink
Merge pull request #20 from sebastienrousseau/feature/mini-functions
Browse files Browse the repository at this point in the history
Feature/mini functions
  • Loading branch information
sebastienrousseau authored Jan 6, 2023
2 parents 57a97a6 + 089b4aa commit 7a44c79
Show file tree
Hide file tree
Showing 17 changed files with 1,230 additions and 90 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Extract version number 📜
id: version
run: |
version=$(grep version Cargo.toml | cut -d '"' -f 2)
version=$(grep version Cargo.toml | cut -d '"' -f 2 | sed 's/^/v/')
echo "version=$version"
- name: Build libraries 🏗
Expand Down Expand Up @@ -86,15 +86,15 @@ jobs:
- name: Create Release 🚀
id: create_release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: ${{ github.workspace }}-CHANGELOG.txt
files: |
packages/mini_functions-$version.tar.gz
packages/mini_functions-${{ steps.version.outputs.version }}.tar.gz
name: ${{ github.workspace }}
release_name: ${{ github.workspace }}
tag_name: ${{ github.workspace }}
tag_name: v${{ steps.version.outputs.version }}
draft: false
prerelease: false
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
"cSpell.words": [
"aarch",
"ABCDEFGHIJKLMNOP",
"ascii",
"binutils",
"blake",
"certutil",
"congruential",
"czvf",
"datetime",
"dylib",
"Funct",
"getrandom",
"github",
"GITHUB",
"gnubin",
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ readme = "README.md"
repository = "https://github.com/sebastienrousseau/mini-functions.git"
resolver = "2" # Enables the new Cargo resolution engine
rust-version = "1.57.0"
version = "0.0.5"
version = "0.0.6"

[badges]
maintenance = { status = "actively-developed" }

[dependencies]
blake3 = "1.3.3"
convert_case = "0.6.0"
image = "0.24.5"
qrcode = "0.12.0"
time = "0.3.17"
Expand Down
165 changes: 125 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

[![Made With Love][mwl]][6]

<!-- markdownlint-disable MD033 -->
<center>

## Highly performant utility and wrapper functions library for Rust 🚀

![Mini Functions][banner]

[![Rust][made-with-rust-badge]][12]
[![Crates.io][crates-badge]][8]
[![Lib.rs][libs-badge]][10]
[![Docs.rs][docs-badge]][9]
Expand All @@ -19,6 +23,8 @@
[Request Feature][3]
[Contributing Guidelines][4]**

</center>

## Welcome to the Mini Functions Library for Rust 👋

`Mini Functions` is a highly performant utility and wrapper functions
Expand Down Expand Up @@ -52,60 +58,67 @@ integration into a variety of projects and applications.
- **Regular Maintenance and Updates** — Regular updates and maintenance
to ensure the library stays up-to-date and reliable.

## Requirements 📋
## Installation 📦

It takes just a few minutes to get up and running with `mini-functions`.

### Requirements

`mini-functions` requires Rust **1.57.0** or later.

## Installation 📦
### Documentation

It takes just a few minutes to get up and running with `mini-functions`.
Check out our [documentation][0] for more information.
> ℹ️ **Info:** Please check out our [website][0] for more information
and find our documentation on [docs.rs][9], [lib.rs][10] and
[crates.io][8].

Add the following to your `Cargo.toml` file:
## Usage 📖

To use `mini-functions` in your project, add the following to your
`Cargo.toml` file:

```toml
[dependencies]
mini-functions = "0.0.5"
mini-functions = "0.0.6"
```

## Usage 📖

Add the following to your `main.rs` file:

```rust
extern crate mini_functions;
use mini_functions::*;
```

then you can use the functions in your application code.

### Examples

`Mini Functions` comes with a set of examples that you can use to get
started. The examples are located in the `examples` directory of the
project. To run the examples, clone the repository and run the following
command in your terminal from the project root directory.

```shell
cargo run --example date
```

> 💡 **Note:** The examples available are date, hash, log, password, qrcode, random and uuid.
## The Functions library 📚

`Mini Functions` is a library of functions for Rust that provides a
collection of tools for working with various aspects of a Rust
application.

The functions in `Mini Functions` are optimized for speed and
efficiency, making them useful for a variety of applications, including
those that require fast performance or that need to handle large amounts
of data.

The `mini-functions` library consists of the following functions:
application. The `mini-functions` library consists of the following
`non-exhaustive` functions:

- The **[Date and time functions](#date-and-time-functions)** are used
to retrieve and manipulate information about dates and times.
- The **[Log functions](#log-functions)** are used to log messages to
the console.
- The **[QRCode functions](#qrcode-functions)** are used to generate
QRCode images and data.
- The **[Random number functions](#random-number-functions)** are used
to generate random numbers in a variety of sizes and formats.
- The **[UUID functions](#uuid-functions)** are used to generate UUIDs
(Universally Unique Identifiers).
### 1) Date and time functions

The following tables provide a brief description of each function in the
`mini-functions` library.
The **Date and time functions** are used to retrieve and manipulate
information about dates and times.

### Date and time functions
<!-- markdownlint-disable MD033 -->
<details>
<summary>Open to view the Date and time functions available in the library<br><br></summary>

| Function | Include File | Function Prototype | Description |
| -------- | ------------ | ------------------ | ----------- |
Expand All @@ -123,15 +136,74 @@ The following tables provide a brief description of each function in the
| `Date::timestamp()` | `date.rs` | `fn timestamp()` | Returns the current timestamp. |
| `Date::weekday()` | `date.rs` | `fn weekday()` | Returns the current weekday. |
| `Date::year()` | `date.rs` | `fn year()` | Returns the current year. |
</details>

### 2) Hash functions

The **Hash functions** are used to generate hashes for various data
types.

### Log functions
<!-- markdownlint-disable MD033 -->
<details>
<summary>Open to view the Hash functions available in the library<br><br></summary>

| Function | Include File | Function Prototype | Description |
| -------- | ------------ | ------------------ | ----------- |
| `Hash::entropy` | `hash.rs` | `fn entropy()` | Returns the entropy of a string. |
| `Hash::generate_hash` | `hash.rs` | `fn generate_hash()` | Generates a hash for a string. |
| `Hash::hash` | `hash.rs` | `fn hash()` | Returns the hash of a string. |
| `Hash::hash_length` | `hash.rs` | `fn hash_length()` | Returns the length of a hash. |
| `Hash::new` | `hash.rs` | `fn new()` | Creates a new hash instance. |
| `Hash::password` | `hash.rs` | `fn password()` | Returns the hash of a password. |
| `Hash::password_length` | `hash.rs` | `fn password_length()` | Returns the length of a password hash. |
| `Hash::set_hash` | `hash.rs` | `fn set_hash()` | Sets the hash for a string. |
| `Hash::set_password` | `hash.rs` | `fn set_password()` | Sets the hash for a password. |
| `Hash::verify` | `hash.rs` | `fn verify()` | Verifies a hash. |
</details>

### 3) Log functions

The **Log functions** are used to log messages to the console.

<!-- markdownlint-disable MD033 -->
<details>
<summary>Open to view the Log functions available in the library<br><br></summary>

| Function | Include File | Function Prototype | Description |
| -------- | ------------ | ------------------ | ----------- |
| `Log::log()` | `log.rs` | `fn log()` | Logs a message to the console.|
| `Log::new()` | `log.rs` | `fn new()` | Creates a new log instance. |
</details>

### 4) Password functions

The **Password functions** are used to generate passwords and verify
passwords.

<!-- markdownlint-disable MD033 -->
<details>
<summary>Open to view the Password functions available in the library<br><br></summary>

| Function | Include File | Function Prototype | Description |
| -------- | ------------ | ------------------ | ----------- |
| `Password::entropy` | `password.rs` | `fn entropy()` | Returns the entropy of a string. |
| `Password::hash_length` | `password.rs` | `fn hash_length()` | Returns the length of a hash. |
| `Password::hash` | `password.rs` | `fn hash()` | Returns the hash of a password. |
| `Password::is_empty` | `password.rs` | `fn is_empty()` | Checks if a password is empty. |
| `Password::len` | `password.rs` | `fn len()` | Returns the length of a password. |
| `Password::new` | `password.rs` | `fn new()` | Creates a new password instance. |
| `Password::passphrase` | `password.rs` | `fn passphrase()` | Generates a passphrase. |
| `Password::password_length` | `password.rs` | `fn password_length()` | Returns the length of a password hash. |
| `Password::set_passphrase` | `password.rs` | `fn set_passphrase()` | Sets a passphrase. |
</details>

### 5) QRCode functions

The **QRCode functions** are used to generate QRCode images and data.

### QRCode functions
<!-- markdownlint-disable MD033 -->
<details>
<summary>Open to view the QRCode functions available in the library<br><br></summary>

| Function | Include File | Function Prototype | Description |
| -------- | ------------ | ------------------ | ----------- |
Expand All @@ -143,8 +215,16 @@ The following tables provide a brief description of each function in the
| `QRCode::to_png()` | `qrcode.rs` | `fn to_png()` | Converts the QRCode instance to a PNG image. |
| `QRCode::to_qrcode()` | `qrcode.rs` | `fn to_qrcode()` | Converts the QRCode instance to a QRCode image. |
| `QRCode::to_svg()` | `qrcode.rs` | `fn to_svg()` | Converts the QRCode instance to a SVG image. |
</details>

### Random number functions
### 6) Random number functions

The **Random number functions** are used to
generate random numbers in a variety of sizes and formats.

<!-- markdownlint-disable MD033 -->
<details>
<summary>Open to view the Random number functions available in the library<br><br></summary>

| Function | Include File | Function Prototype | Description |
| -------- | ------------ | ------------------ | ----------- |
Expand All @@ -155,26 +235,31 @@ The following tables provide a brief description of each function in the
| `Random::new()` | `random.rs` | `fn new()` | Creates a new `Random` struct with a seed based on the current system time. |
| `Random::pseudo()` | `random.rs` | `fn pseudo()` | Generates a pseudo-random number by XORing the last 31 random numbers together. |
| `Random::random()` | `random.rs` | `fn random()` | Generates a random number using the linear congruential generator algorithm. The multiplier for the algorithm is the golden ratio. |
</details>

### 7) UUID functions

### UUID functions
The **UUID functions** are used to generate UUIDs (Universally Unique
Identifiers).

<!-- markdownlint-disable MD033 -->
<details>
<summary>Open to view the UUID functions available in the library<br><br></summary>

| Function | Include File | Function Prototype | Description |
| -------- | ------------ | ------------------ | ----------- |
| `UUID::new()` | `uuid.rs` | `fn new()` | Creates a new UUID instance based on the version specified. (v3, v4, v5) |
| `UUID::uuid_v3()` | `uuid.rs` | `fn uuid_v3()` | Creates a new UUID v3 instance. |
| `UUID::uuid_v4()` | `uuid.rs` | `fn uuid_v4()` | Creates a new UUID v4 instance. |
| `UUID::uuid_v5()` | `uuid.rs` | `fn uuid_v5()` | Creates a new UUID v5 instance. |

![divider][divider]
</details>

## Semantic Versioning Policy 🚥

For transparency into our release cycle and in striving to maintain
backward compatibility, `Mini Functions` follows
[semantic versioning][7].

![divider][divider]

## License 📝

The project is licensed under the terms of both the MIT license and the
Expand All @@ -183,8 +268,6 @@ Apache License (Version 2.0).
- [Apache License, Version 2.0][1]
- [MIT license][2]

![divider][divider]

## Contribution 🤝

Unless you explicitly state otherwise, any contribution intentionally
Expand All @@ -209,11 +292,13 @@ for their help and support.
[8]: https://crates.io/crates/mini-functions
[9]: https://docs.rs/mini-functions
[10]: https://lib.rs/crates/mini-functions
[12]: https://www.rust-lang.org/

[banner]: https://raw.githubusercontent.com/sebastienrousseau/vault/main/assets/banners/banner-mini-functions.svg "Mini Functions - Rust 🦀"
[crates-badge]: https://img.shields.io/crates/v/mini-functions.svg?style=for-the-badge 'Crates.io'
[divider]: https://raw.githubusercontent.com/sebastienrousseau/vault/main/assets/elements/divider.svg "divider"
[docs-badge]: https://img.shields.io/docsrs/mini-functions.svg?style=for-the-badge 'Docs.rs'
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.5-orange.svg?style=for-the-badge 'Lib.rs'
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.6-orange.svg?style=for-the-badge 'Lib.rs'
[license-badge]: https://img.shields.io/crates/l/mini-functions.svg?style=for-the-badge 'License'
[made-with-rust-badge]: https://raw.githubusercontent.com/sebastienrousseau/vault/main/assets/shields/made-with-rust.svg "Made With Rust 🦀"
[mwl]: https://raw.githubusercontent.com/sebastienrousseau/vault/main/assets/shields/made-with-love.svg "Made With Love"
51 changes: 51 additions & 0 deletions examples/hash.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use mini_functions::hash::Hash;

fn main() {
let mut hash = Hash::new();
let mut default = Hash::default();
let is_valid = hash.verify(
"7f2611ba158b6dcea4a69c229c303358c5e04493abeadee106a4bfa464d55787",
"password",
);
hash.set_password("password");
default.set_password("password");
hash.set_hash("1.61803398874989484820");
default.set_hash("1.61803398874989484820");

println!("🦀 Hash::new(): ✅ {}", hash);
println!("🦀 Hash::default(): ✅ {}", default);
println!("🦀 Hash::generate_hash(): ✅ {}", hash.generate_hash());
if is_valid {
println!(
"🦀 Hash::verify(): ✅ {}",
hash.verify(hash.hash(), "password")
);
} else {
println!("🦀 Hash::verify() : ❌ The password or hash is invalid.");
}
println!(
"🦀 Hash::set_password(): ✅ {}",
hash.password() == "password"
);
println!(
"🦀 Hash::set_hash(): ✅ {}",
hash.hash() == "1.61803398874989484820"
);
println!(
"🦀 Hash::password(): ✅ {}",
hash.password() == "password"
);
println!(
"🦀 Hash::password_length(): ✅ {}",
hash.password_length() == 8
);
println!(
"🦀 Hash::hash(): ✅ {}",
hash.hash() == "1.61803398874989484820"
);
println!(
"🦀 Hash::hash_length(): ✅ {}",
hash.hash_length() == 22
);
println!("🦀 Hash::entropy(): ✅ {}", hash.entropy() > 0.0);
}
Loading

0 comments on commit 7a44c79

Please sign in to comment.