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
|
use passwordmaker_rs::{PasswordMaker, Hasher, HasherList, HashAlgorithm};
use digest::Digest;
use md4;
use md5;
use sha1;
use sha2;
use ripemd;
struct Md4;
struct Md5;
struct Sha1;
struct Sha256;
struct RipeMD160;
impl Hasher for Md4{
type Output = [u8;16];
fn hash(data : &[u8]) -> Self::Output {
md4::Md4::digest(data).into()
}
}
impl Hasher for Md5{
type Output = [u8;16];
fn hash(data : &[u8]) -> Self::Output {
md5::Md5::digest(data).into()
}
}
impl Hasher for Sha1{
type Output = [u8;20];
fn hash(data : &[u8]) -> Self::Output {
sha1::Sha1::digest(data).into()
}
}
impl Hasher for Sha256{
type Output = [u8;32];
fn hash(data : &[u8]) -> Self::Output {
sha2::Sha256::digest(data).into()
}
}
impl Hasher for RipeMD160{
type Output = [u8;20];
fn hash(data : &[u8]) -> Self::Output {
ripemd::Ripemd160::digest(data).into()
}
}
impl passwordmaker_rs::Md4 for Md4{}
impl passwordmaker_rs::Md5 for Md5{}
impl passwordmaker_rs::Sha1 for Sha1{}
impl passwordmaker_rs::Sha256 for Sha256{}
impl passwordmaker_rs::Ripemd160 for RipeMD160{}
struct Hashes{}
impl HasherList for Hashes {
type MD4 = Md4;
type MD5 = Md5;
type SHA1 = Sha1;
type SHA256 = Sha256;
type RIPEMD160 = RipeMD160;
}
type Pwm<'a> = PasswordMaker<'a, Hashes>;
#[test]
fn default_settings() {
let pwm = Pwm::new(
HashAlgorithm::Md5,
passwordmaker_rs::UseLeetWhenGenerating::NotAtAll,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./",
"",
"",
8,
"",
""
).unwrap();
let result = pwm.generate(".abcdefghij".to_owned(), "1".to_owned()).unwrap();
assert_eq!(result, "J3>'1F\"/");
}
|