pub fn scramble_native(nonce: &[u8], password: &[u8]) -> Option<[u8; 20]> {
    fn sha1_1(bytes: impl AsRef<[u8]>) -> [u8; 20] {
        let mut hasher = Sha1::default();
        hasher.update(bytes.as_ref());
        hasher.digest().bytes()
    }

    fn sha1_2(bytes1: impl AsRef<[u8]>, bytes2: impl AsRef<[u8]>) -> [u8; 20] {
        let mut hasher = Sha1::default();
        hasher.update(bytes1.as_ref());
        hasher.update(bytes2.as_ref());
        hasher.digest().bytes()
    }

    if password.is_empty() {
        return None;
    }

    Some(xor(
        sha1_1(password),
        sha1_2(nonce, sha1_1(sha1_1(password))),
    ))
}
/// Scramble algorithm used in mysql_native_password.
///
/// SHA1(password) XOR SHA1(nonce, SHA1(SHA1(password)))
Scramble algorithm used in mysql_native_password.
Scramble algorithm used in mysql_native_password .
pub fn scramble_native(nonce: &[u8], password: &[u8]) -> Option<[u8; 20]> {
    fn sha1_1(bytes: impl AsRef<[u8]>) -> [u8; 20] {
        let mut hasher = Sha1::default();
        hasher.update(bytes.as_ref());
        hasher.digest().bytes()
    }
    fn sha1_2(bytes1: impl AsRef<[u8]>, bytes2: impl AsRef<[u8]>) -> [u8; 20] {
        let mut hasher = Sha1::default();
        hasher.update(bytes1.as_ref());
        hasher.update(bytes2.as_ref());
        hasher.digest().bytes()
    }
    if password.is_empty() {
        return None;
    }
    Some(xor(
        sha1_1(password),
        sha1_2(nonce, sha1_1(sha1_1(password))),
    ))
}
pub fn scramble_native ( nonce : & [ u8 ] , password : & [ u8 ] ) -> Option < [ u8 ; 20 ] > { fn sha1_1 ( bytes : impl AsRef < [ u8 ] > ) -> [ u8 ; 20 ] { let mut hasher = Sha1 :: default ( ) ; hasher . update ( bytes . as_ref ( ) ) ; hasher . digest ( ) . bytes ( ) } fn sha1_2 ( bytes1 : impl AsRef < [ u8 ] > , bytes2 : impl AsRef < [ u8 ] > ) -> [ u8 ; 20 ] { let mut hasher = Sha1 :: default ( ) ; hasher . update ( bytes1 . as_ref ( ) ) ; hasher . update ( bytes2 . as_ref ( ) ) ; hasher . digest ( ) . bytes ( ) } if password . is_empty ( ) { return None ; } Some ( xor ( sha1_1 ( password ) , sha1_2 ( nonce , sha1_1 ( sha1_1 ( password ) ) ) , ) ) }
Scramble algorithm used in mysql_native_password.
Scramble algorithm used in mysql_native_password .
nonce
&[u8]
password
&[u8]
nonce
&[u8]
password
&[u8]