summaryrefslogtreecommitdiff
path: root/src/stable/crypt.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
commitec05778d5718a7912e506764d443a78d6a6179e3 (patch)
tree78a9a01532180030c095acefc45763f07c14edb8 /src/stable/crypt.cpp
parentb20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff)
downloadlibbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/stable/crypt.cpp')
-rw-r--r--src/stable/crypt.cpp38
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
14Bu::String Bu::cryptPass( const Bu::String &sPass, const Bu::String &sSalt ) 14Bu::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
32Bu::String Bu::cryptPass( const Bu::String &sPass ) 32Bu::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