Skip to main content

detect_hash_algorithm

Function detect_hash_algorithm 

Source
pub fn detect_hash_algorithm(hash: &str) -> HashAlgorithm
Expand description

Detect hash algorithm from hash length

Returns:

  • SHA-256 for 64 character hashes
  • SHA-384 for 96 character hashes (default)
  • SHA-512 for 128 character hashes

ยงExample

use atlas_common::hash::{detect_hash_algorithm, HashAlgorithm};

let sha256_hash = "a".repeat(64);
assert_eq!(detect_hash_algorithm(&sha256_hash), HashAlgorithm::Sha256);