1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//! Create keys, uuid's, timestamps, and more with Rust..
//!
//!
//! Here's some example keys:
//!
//! ```text
//! 5WdT@KfYRyRDqh0AAVUsyitSXbm4OQwzClX9.XYn5kLmKeObCf8YE3HqzHdU3UTS
//! g1Y_Zp9-9rDf7VAaR1KGnH9Uf5klGjSQ6P2rAjK35iK-GnZ@dVXYu.aElzTfTOaK
//! M3rkxIbrD0lz-SpUBe704X2)Gd(_WprzRJW7N51O@_58180Gs9esIVBO5.OdFOlY
//! ```
//!
//! This looks like gibberish, but that's the point. Two id's in a database should not overlap.
//! So if you need a lot of entries, you need to reduce the odds of that happening.
//! If the odds of two identical id's are astronomically low, you shouldn't even need to check for an existing id in the first place.
//! Keysmith does that generation for you and outputs it as a String.
//!
//! You can also generate version 4 UUID's. Examples:
//! ```text
//! be3b5529-931b-6b75-1678-a057bccf71c9
//! 440146ab-a19a-8a36-2d4b-ba19a79570d4
//! 0090da40-6ce2-59d3-629d-11b293c9e2d3
//! ```
//!
//! Keysmith also supports many other data formats.
//! - Keys strings from custom character sets
//! - "Nonstandard" V4 UUID's using any letter as opposed to just a-f
//! - Timestamps (ex: 50546851)
//! - Dates (ex: 2023-07-17), times (ex: 19:34:07), and datetimes (ex: 2023-07-17T19:34:07)
//! - Individual characters
//!
//! # Usage
//!
//! First, add this to your `Cargo.toml` dependencies.
//! Check out the [crate page](https://crates.io/crates/keysmith) to make sure you're using the latest version.
//!
//! ```toml
//! [dependencies]
//! keysmith = "0.4.0"
//! ```
//! Next, in the actual code:
//!
//! ```
//! use keysmith::{key, uuid};
//!
//! let key1: String = key::key(64);
//! println!("{}", key1);
//! // ex: aVCkmMFkv3UqLIU2tC52DQOWrIg4RsaH.xvTCTvA_PVHY@MOIWH~y1610KIZ@qM@
//!
//! let key2: String = uuid::uuid();
//! println!("{}", key2);
//! // ex: da748b8b-e915-661b-466a-0d6a0480112a
//!
//! let key3: String = uuid::uuidn();
//! println!("{}", key3);
//! // "Nonstandard" UUID
//! // ex: eko0c6ph-k2ok-60rr-pj78-mns182t9vurf
//! ```
//! The first function generates a key with a length of 64 characters as a String.
//! The second generates a version 4 UUID.
//! The third generates a "nonstandard" UUID.
//! It uses the same structure as a version 4, but it can have any letter instead of just a-f.
//! The "nonstandard" version is obviously not standard,
//! but may be useful depending on your preferences.
//!
//!
//! You can also generate a key consisting of only a specific kind of character.
//!
//! ```
//! use keysmith::key;
//!
//! let key1: String = key::key(32);
//! println!("{}", key1);
//! // ex: 04356417134317004828941212534445
//!
//! let key2: String = key::letters(32);
//! println!("{}", key2);
//! // ex: PBSZWwSTmRalGnzeSbQUKmXRikKUWXvj
//!
//! let key3: String = key::special_chars(32);
//! println!("{}", key3);
//! // Special characters generally considered "safe."
//! // Possible characters: -_.()~@
//! // ex: )@-_~@_@._))~)@))@.)(-)@(.@(~((@
//! ```
//!
//! If you want only lowercase or uppercase letters, you can do that, too!
//!
//! ```
//! use keysmith::key;
//!
//! let key1: String = key::letters_lower(32);
//! println!("{}", key1);
//! // ex: xoewhgvjsqzctfgpaqwnhanbgweflpqc
//!
//! let key2: String = key::letters_upper(32);
//! println!("{}", key2);
//! // ex: EVQMPIHKDBPLZJBPCHTXTIBLYRSFFFUY
//! ```
//!
//! If you need something more specific than what's already here by default,
//! you can generate a single char.
//!
//! ```
//! use keysmith::char::{char, GenCharOpts};
//!
//! let opts = GenCharOpts {
//! nums: true,
//! letters: true,
//! upper: true,
//! safe_sp_chars: true,
//! unsafe_sp_chars: false,
//! };
//!
//! let c: char = char(opts);
//! println!("{}", c);
//! // ex: H
//! ```
//!
//! Or just use your own character set.
//!
//! ```
//! use keysmith::key;
//!
//! let charset = String::from("among_us");
//! let key: String = key::key_custom(32, charset);
//! println!("{}", key);
//!
//! // ex: unnusgnggauogoauusu__msguo_gmomg
//! ```
//!
//! Keysmith also lets you get a timestamp.
//! This is in seconds since the first second of 2022.
//! String is the default type for this, but you can also return an i64.
//! ```
//! use keysmith::timestamp;
//!
//! let stamp: String = timestamp::timestamp();
//! let stamp2: i64 = timestamp::timestamp_i64();
//!
//! println!("{}", stamp);
//! println!("{}", stamp2);
//! // ex: 25928414
//! ```
//!
//! Timestamps can also be in milliseconds.
//!
//! ```
//! use keysmith::timestamp;
//!
//! let stamp: String = timestamp::timestamp();
//! let stamp2: i64 = timestamp::timestamp_i64();
//!
//! println!("{}", stamp);
//! println!("{}", stamp2);
//! // ex: 25928414
//! ```
//!
//! Finally, you can get the current date or time.
//!
//! ```
//! use keysmith::date;
//!
//! let date: String = date::date();
//! let time: String = date::time();
//! let datetime: String = date::datetime();
//!
//! println!("{}", date); // ex: 2023-08-16
//! println!("{}", time); // ex: 19:29:10
//! println!("{}", datetime); // ex: 2023-08-16T19:29:10
//! ```
//!
//! Those were just the basics. For more functionality, see the modules below.