random-string
A simple crate that allows you to generate random strings based on a given charset and length.
Description
This is just a test crate for my personal use, and I don't think that there would be more updates.
If you would like to change or add something, or even create a better version feel free to do so.
I've learned some new things and wanted to avoid humiliation from 0.1.1
"Benchmark"
Generating 3 times 100000 results with length 10 and Letters charset.
version 0.1.1
Benchmark: 3.3298s
Benchmark: 3.3292s
Benchmark: 3.3292s
version 0.1.2
Benchmark: 0.659s
Benchmark: 0.634s
Benchmark: 0.635s
test src
Usage
Add a dependence in Cargo.toml
[]
= "0.1.2"
Functions
Charset::from_charsets(Charsets)
-> Vec<char>
Get a ready charset by passing an enum Charsets
.
The output is a Vector containing certain characters that will be used in the generation.
Charset::from_str(&str)
-> Vec<char>
Create a charset by passing an &str
.
The output is a Vector containing certain characters that will be used in the generation.
RandomString::generate(i32, &Vec<char>)
-> GenerationResult
Generate a random Vector containing characters with a certain length as i32
and based on a &Vec<char>
charset.
The output is a GenerationResult
.
GenerationResult.to_string()
-> String
Convert the GenerationResult
into a String
.
Enums
Use this enum in RandomString::get_charset
function to get a charset.
Examples
use ;