## bin+lib cmn

A Rust library for accessing a collection of mathematical and cryptographic constants

### 3 releases

 0.0.3 May 13, 2023 Feb 9, 2023 Feb 5, 2023

#392 in Cryptography

Used in psph

MIT/Apache

81KB
922 lines

# Common (CMN)

A Rust library for accessing a collection of mathematical and cryptographic constants

Part of the Mini Functions family of libraries.

## Overview 📖

`Common (CMN)` is a modern, fast, and user-friendly library that makes it easy to access a wide range of mathematical and cryptographic constants.

## Features ✨

The `Common (CMN)` uses the `serde` crate to serialize and deserialize the data.

The library has three modules:

• Macros: This module contains functions for generating macros that can be used to access the constants.
• Constants: This module contains the Constants structure, which provides a collection of constant values that are used throughout the library.
• Words: This module contains the Words structure, which provides a collection of words that are used throughout the library.

### Mathematical and Cryptographic Constants

The following table lists the most important mathematical and cryptographic constants available in the `Common (CMN)` library:

Constants Description Example
AVOGADRO Avogadro's constant is the number of atoms or molecules in one mole of a substance. The number of atoms in 12 grams of carbon-12 is 6.02214076 × 10^23. This can be used to calculate the number of atoms or molecules in a given sample.
BOLTZMANN Boltzmann's constant is the physical constant relating the temperature of a system to the average kinetic energy of its constituent particles. The kinetic energy of an atom at room temperature is about 2.0 × 10^-21 joules. This can be used to calculate the temperature of a system, or to calculate the average kinetic energy of its particles.
EULER Euler's constant is a mathematical constant approximately equal to 2.71828. The sum of the infinite series 1 + 1/2 + 1/3 + ... is equal to Euler's constant, e. This can be used to calculate the sum of an infinite series, or to calculate the logarithm of a number.
GAMMA The gamma constant is a mathematical constant approximately equal to 0.57721. The gamma function of 2 is equal to 1. This can be used to calculate the gamma function of a number, or to calculate the factorial of a number.
HASH_ALGORITHM The hash algorithm used to generate the hash. The default is Blake3. The hash of the string "Hello, world!" is 5eb63bbbe01eeed093cb22bb8f5acdc32790160b123138d53f2173b8d3dc3eee. This can be used to verify the integrity of data, or to create a unique identifier for a file.
HASH_COST The cost of the hash. The hash cost of Blake3 is 2^128. This can be used to determine how secure a hash algorithm is.
HASH_LENGTH The length of the hash. The hash length of Blake3 is 32 bytes. This can be used to determine how much space is required to store the hash output.
PHI The golden ratio is a number approximately equal to 1.618033988749895. The golden ratio can be used to create a symmetrical design, or a design that is pleasing to the eye.
Pi (π) Pi is the ratio of a circle's circumference to its diameter. The circumference of a circle with a radius of 1 is equal to pi. This can be used to calculate the circumference, area, and volume of circles, spheres, and other geometric shapes.
PLANCK Planck's constant is a physical constant that is approximately equal to 6.62607015 × 10^−34 joule seconds. The energy of a photon of light with a wavelength of 500 nanometers is equal to Planck's constant multiplied by the frequency of the light. This can be used to calculate the energy of photons and other elementary particles.
SILVER_RATIO The silver ratio is a number approximately equal to 1.414213562373095. The silver ratio can be used to create a symmetrical design, or a design that is pleasing to the eye.
SPECIAL_CHARS A list of special characters. The special characters are: !@#\$%^&*()_+-={}[]
SQRT2 The square root of 2 is a number approximately equal to 1.414213562373095. The area of a circle with a radius of 1 is equal to the square root of 2. This can be used to calculate the area and volume of circles, spheres, and other geometric shapes.
SQRT3 The square root of 3 is a number approximately equal to 1.732050807568877. The area of a circle with a radius of 1 is equal to the square root of 3. This can be used to calculate the area and volume of circles
SQRT5 The square root of 5 is a number approximately equal to 2.23606797749979. The area of a circle with a radius of 1 is equal to the square root of 5.
TAU Tau is a number approximately equal to 6.283185307179586. The circumference of a circle with a radius of 1 is equal to tau.

## Getting Started 🚀

It takes just a few minutes to get up and running with `Common (CMN)`.

### Installation

To install `Common (CMN)`, you need to have the Rust toolchain installed on your machine. You can install the Rust toolchain by following the instructions on the Rust website.

Once you have the Rust toolchain installed, you can install `Common (CMN)` using the following command:

``````cargo install cmn
``````

You can then run the help command to see the available options:

``````cmn --help
``````

### Requirements

The minimum supported Rust toolchain version is currently Rust 1.69.0 or later (stable). It is recommended that you install the latest stable version of Rust.

### Platform support

`Common (CMN)` is supported and tested on the following platforms:

#### Tier 1 platforms 🏆

Operating System Target Description
Linux aarch64-unknown-linux-gnu 64-bit Linux systems on ARM architecture
Linux i686-unknown-linux-gnu 32-bit Linux (kernel 3.2+, glibc 2.17+)
Linux x86_64-unknown-linux-gnu 64-bit Linux (kernel 2.6.32+, glibc 2.11+)
macOS x86_64-apple-darwin 64-bit macOS (10.7 Lion or later)
Windows i686-pc-windows-gnu 32-bit Windows (7 or later)
Windows i686-pc-windows-msvc 32-bit Windows (7 or later)
Windows x86_64-pc-windows-gnu 64-bit Windows (7 or later)
Windows x86_64-pc-windows-msvc 64-bit Windows (7 or later)

#### Tier 2 platforms 🥈

Operating System Target Description
64-bit Linux x86_64-unknown-linux-musl 64-bit Linux (kernel 2.6.32+, musl libc)
ARM64 Linux aarch64-unknown-linux-musl 64-bit Linux systems on ARM architecture
ARM64 macOS aarch64-apple-darwin 64-bit macOS on Apple Silicon
ARM64 Windows aarch64-pc-windows-msvc 64-bit Windows (aarch64-pc-windows-msvc)
ARMv6 Linux arm-unknown-linux-gnueabi ARMv6 Linux (kernel 3.2, glibc 2.17)
ARMv6 Linux, hardfloat arm-unknown-linux-gnueabihf ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17)
ARMv7 Linux, hardfloat armv7-unknown-linux-gnueabihf ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17)
FreeBSD x86_64-unknown-freebsd 64-bit FreeBSD on x86-64
MIPS (LE) Linux mipsel-unknown-linux-gnu MIPSel Linux (kernel 2.6.32+, glibc 2.11+)
MIPS Linux mips-unknown-linux-gnu MIPS Linux (kernel 2.6.32+, glibc 2.11+)
MIPS64 (LE) Linux mips64el-unknown-linux-gnuabi64 MIPS64el Linux (kernel 2.6.32+, glibc 2.11+)
MIPS64 Linux mips64-unknown-linux-gnuabi64 MIPS64 Linux (kernel 2.6.32+, glibc 2.11+)
NetBSD x86_64-unknown-netbsd 64-bit NetBSD on x86-64
PowerPC Linux powerpc-unknown-linux-gnu PowerPC Linux (kernel 3.2, glibc 2.17)
PPC64 Linux powerpc64-unknown-linux-gnu PowerPC64 Linux (kernel 3.2, glibc 2.17)
PPC64LE Linux powerpc64le-unknown-linux-gnu PowerPC64le Linux (kernel 3.2, glibc 2.17)
RISC-V Linux riscv64gc-unknown-linux-gnu RISC-V Linux (kernel 3.2, glibc 2.17)
S390x Linux s390x-unknown-linux-gnu s390x Linux (kernel 3.2, glibc 2.17)

The GitHub Actions shows the platforms in which the `Common (CMN)` library tests are run.

### Documentation

ℹ️ Info: Please check out our website for more information. You can find our documentation on docs.rs, lib.rs and crates.io.

## Usage 📖

To use the `Common (CMN)` library in your project, add the following to your `Cargo.toml` file:

``````[dependencies]
cmn = "0.0.3"
``````

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

``````extern crate cmn;
use cmn::*;
``````

then you can use the functions in your application code.

### Examples

`Common (CMN)` 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.

``````cargo run --example cmn
``````

## Semantic Versioning Policy 🚥

For transparency into our release cycle and in striving to maintain backward compatibility, `Common (CMN)` follows semantic versioning.

## Contribution 🤝

Contributions in any form (issues, pull requests, etc.) to this project must adhere to the Rust's Code of Conduct.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

## Acknowledgements 💙

A big thank you to all the awesome contributors of the Common (CMN) Library for their help and support.

A special thank you goes to the Rust Reddit community for providing a lot of useful suggestions on how to improve this project.

~0.7–1.4MB
~32K SLoC