diff options
Diffstat (limited to '')
-rw-r--r-- | src/stable/crypt.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/stable/crypt.cpp b/src/stable/crypt.cpp index 3f7fc83..2915cf4 100644 --- a/src/stable/crypt.cpp +++ b/src/stable/crypt.cpp | |||
@@ -13,35 +13,35 @@ | |||
13 | 13 | ||
14 | Bu::String Bu::cryptPass( const Bu::String &sPass, const Bu::String &sSalt ) | 14 | Bu::String Bu::cryptPass( const Bu::String &sPass, const Bu::String &sSalt ) |
15 | { | 15 | { |
16 | Bu::Md5 md5; | 16 | Bu::Md5 md5; |
17 | Bu::MemBuf mbOut; | 17 | Bu::MemBuf mbOut; |
18 | Bu::Base64 b64Out( mbOut ); | 18 | Bu::Base64 b64Out( mbOut ); |
19 | 19 | ||
20 | Bu::String::const_iterator i = sSalt.find('$'); | 20 | Bu::String::const_iterator i = sSalt.find('$'); |
21 | Bu::String sSaltSml = sSalt.getSubStr( sSalt.begin(), i ); | 21 | Bu::String sSaltSml = sSalt.getSubStr( sSalt.begin(), i ); |
22 | 22 | ||
23 | md5.addData( sPass ); | 23 | md5.addData( sPass ); |
24 | md5.addData( sSaltSml ); | 24 | md5.addData( sSaltSml ); |
25 | md5.writeResult( b64Out ); | 25 | md5.writeResult( b64Out ); |
26 | 26 | ||
27 | b64Out.stop(); | 27 | b64Out.stop(); |
28 | 28 | ||
29 | return sSaltSml + "$" + mbOut.getString(); | 29 | return sSaltSml + "$" + mbOut.getString(); |
30 | } | 30 | } |
31 | 31 | ||
32 | Bu::String Bu::cryptPass( const Bu::String &sPass ) | 32 | Bu::String Bu::cryptPass( const Bu::String &sPass ) |
33 | { | 33 | { |
34 | Bu::MemBuf mbSalt; | 34 | Bu::MemBuf mbSalt; |
35 | Bu::Base64 b64Salt( mbSalt ); | 35 | Bu::Base64 b64Salt( mbSalt ); |
36 | Bu::File fRand("/dev/urandom", Bu::File::Read ); | 36 | Bu::File fRand("/dev/urandom", Bu::File::Read ); |
37 | 37 | ||
38 | #define STR 6 | 38 | #define STR 6 |
39 | char buf[STR]; | 39 | char buf[STR]; |
40 | fRand.read( buf, STR ); | 40 | fRand.read( buf, STR ); |
41 | b64Salt.write( buf, STR ); | 41 | b64Salt.write( buf, STR ); |
42 | 42 | ||
43 | b64Salt.stop(); | 43 | b64Salt.stop(); |
44 | 44 | ||
45 | return cryptPass( sPass, mbSalt.getString() ); | 45 | return cryptPass( sPass, mbSalt.getString() ); |
46 | } | 46 | } |
47 | 47 | ||