File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed
Sources/PostgreSQL/Connection Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -113,20 +113,12 @@ public final class PostgreSQLConnection {
113113 throw PostgreSQLError ( identifier: " usernameUTF8 " , reason: " Could not convert username to UTF-8 encoded Data. " , source: . capture( ) )
114114 }
115115
116- let hasher = MD5 ( )
117116 // pwdhash = md5(password + username).hexdigest()
118- var passwordUsernameData = passwordData + usernameData
119- hasher. update ( sequence: & passwordUsernameData)
120- hasher. finalize ( )
121- guard let pwdhash = hasher. hash. hexString. data ( using: . utf8) else {
122- throw PostgreSQLError ( identifier: " hashUTF8 " , reason: " Could not convert password hash to UTF-8 encoded Data. " , source: . capture( ) )
123- }
124- hasher. reset ( )
125- // hash = ′ md 5′ + md 5(pwdhash + salt ).hexdigest ()
126- var saltedData = pwdhash + salt
127- hasher. update ( sequence: & saltedData)
128- hasher. finalize ( )
129- let passwordMessage = PostgreSQLPasswordMessage ( password: " md5 " + hasher. hash. hexString)
117+ let pwdhash = try MD5 . digest ( passwordData + usernameData) . hexEncodedString ( )
118+ // hash = "md5" + md 5(pwdhash + salt).hexdigest()
119+ let hash = try " md5 " + MD5. digest ( Data ( pwdhash. utf8) + salt) . hexEncodedString ( )
120+
121+ let passwordMessage = PostgreSQLPasswordMessage ( password: hash)
130122 input = [ . password( passwordMessage) ]
131123 }
132124
You can’t perform that action at this time.
0 commit comments