Skip to main content

md5_password

Function md5_password 

Source
pub fn md5_password(username: &str, password: &str, salt: &[u8; 4]) -> BytesMut
Expand description

Computes the MD5 password hash for Postgres authentication.

The hash is computed as: md5(md5(password + username) + salt)

§Arguments

  • username - The database username
  • password - The user’s password
  • salt - The 4-byte salt provided by the server

§Returns

A BytesMut containing the password message ready to be sent.

§Example

use pg_stream::auth::md5_password;

let salt = [0x12, 0x34, 0x56, 0x78];
let msg = md5_password("postgres", "secret", &salt);
// Send msg to the server