pub fn scramble_sha256(nonce: &[u8], password: &[u8]) -> Option<[u8; 32]> {
    fn sha256_1(bytes: impl AsRef<[u8]>) -> [u8; 32] {
        let mut hasher = Sha256::default();
        hasher.input(bytes.as_ref());
        to_u8_32(hasher.result())
    }

    fn sha256_2(bytes1: impl AsRef<[u8]>, bytes2: impl AsRef<[u8]>) -> [u8; 32] {
        let mut hasher = Sha256::default();
        hasher.input(bytes1.as_ref());
        hasher.input(bytes2.as_ref());
        to_u8_32(hasher.result())
    }

    if password.is_empty() {
        return None;
    }

    Some(xor(
        sha256_1(password),
        sha256_2(sha256_1(sha256_1(password)), nonce),
    ))
}
/// Scramble algorithm used in cached_sha2_password fast path.
///
/// XOR(SHA256(password), SHA256(SHA256(SHA256(password)), nonce))
Scramble algorithm used in cached_sha2_password fast path.
Scramble algorithm used in cached_sha2_password fast path .
pub fn scramble_sha256(nonce: &[u8], password: &[u8]) -> Option<[u8; 32]> {
    fn sha256_1(bytes: impl AsRef<[u8]>) -> [u8; 32] {
        let mut hasher = Sha256::default();
        hasher.input(bytes.as_ref());
        to_u8_32(hasher.result())
    }
    fn sha256_2(bytes1: impl AsRef<[u8]>, bytes2: impl AsRef<[u8]>) -> [u8; 32] {
        let mut hasher = Sha256::default();
        hasher.input(bytes1.as_ref());
        hasher.input(bytes2.as_ref());
        to_u8_32(hasher.result())
    }
    if password.is_empty() {
        return None;
    }
    Some(xor(
        sha256_1(password),
        sha256_2(sha256_1(sha256_1(password)), nonce),
    ))
}
pub fn scramble_sha256 ( nonce : & [ u8 ] , password : & [ u8 ] ) -> Option < [ u8 ; 32 ] > { fn sha256_1 ( bytes : impl AsRef < [ u8 ] > ) -> [ u8 ; 32 ] { let mut hasher = Sha256 :: default ( ) ; hasher . input ( bytes . as_ref ( ) ) ; to_u8_32 ( hasher . result ( ) ) } fn sha256_2 ( bytes1 : impl AsRef < [ u8 ] > , bytes2 : impl AsRef < [ u8 ] > ) -> [ u8 ; 32 ] { let mut hasher = Sha256 :: default ( ) ; hasher . input ( bytes1 . as_ref ( ) ) ; hasher . input ( bytes2 . as_ref ( ) ) ; to_u8_32 ( hasher . result ( ) ) } if password . is_empty ( ) { return None ; } Some ( xor ( sha256_1 ( password ) , sha256_2 ( sha256_1 ( sha256_1 ( password ) ) , nonce ) , ) ) }
Scramble algorithm used in cached_sha2_password fast path.
Scramble algorithm used in cached_sha2_password fast path .
nonce
&[u8]
password
&[u8]
nonce
&[u8]
password
&[u8]