random_str

Crates.iorandom_str
lib.rsrandom_str
version0.1.2
sourcesrc
created_at2023-02-19 05:02:40.571331
updated_at2023-06-20 19:16:56.466927
descriptionGenerate random strings, chars, booleans, and integers.
homepage
repository
max_upload_size
id788653
size9,701
Francisco Torres (DeimosHall)

documentation

README

random_str

Generate random strings, chars, booleans, and integers.

What can you do?

If you want to create random texts, phone numbers, or passwords, you can use random_str to do so.

Visit the Github repository: https://github.com/DeimosHall/random_str

Requirements

You need to have installed cargo on your system.

If you are using Windows, download the installer from the official page in the following link:

https://www.rust-lang.org/tools/install

If you are using macOS, GNU/Linux, WSL or a UNIX based system just type:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

How to use it

Create a project.

cargo new my_project

In your Cargo.toml file, add the following dependency:

[dependencies]
random_str = "0.1.2"

Use cargo build to download the dependency.

cargo build

In your main.rs file write the following:

use random_str as random;

fn main() {
    let lowercase = true;
    let uppercase = true;

    let random_letter = random::get_letter(lowercase, uppercase);
    println!("Random letter: {}", random_letter);

    let random_symbol = random::get_symbol();
    println!("Random symbol: {}", random_symbol);

    let mut min = 0;
    let mut max = 9;
    let random_number = random::get_int(min, max);
    println!("Random number: {}", random_number);

    min = 1000000;
    max = 9999999;
    let seven_digits = random::get_int(min, max); // 7 digits
    let random_phone_number = format!("+52 343{}", seven_digits);
    println!("Random phone number: {}", random_phone_number);

    let length = 16;
    let numbers = true;
    let symbols = true;
    let random_password = random::get_string(length, lowercase, uppercase, numbers, symbols);
    println!("Random password: {}", random_password);

    let random_bool = random::get_bool();
    println!("Random bool: {}", random_bool);

    let random_char = random::get_char();
    println!("Random char: {}", random_char);
}

Use cargo run to test the result.

cargo run

Possible output:

random_str on  main [!] via 🦀 v1.69.0
❯ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/main`
Random letter: b
Random symbol: $
Random number: 7
Random phone number: +52 3431550168
Random password: ovnaLx1A%NCric1H
Random bool: true
Random char: ^

How to contribute

If you think there is a function that may be helpful, you can open a pull request. Please, follow the next steps.

  1. Make a fork of the repository.

Note: Be sure to uncheck the option Copy the main branch only.

  1. Clone the repositoy.
git clone https://github.com/username/random_str.git

Note: Replace username with your Github username.

  1. Change to the contribute branch.
git checkout contribute
  1. Update the contribute branch.
git merge main
  1. Commit your changes using Conventional Commits. For example:
git commit -m "feat: add random float"
  1. Push your changes to the contribute branch.
git push origin contribute
  1. Open a pull request. I will check it and make the merge to the main branch.
Commit count: 0

cargo fmt