1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
#![deny(missing_docs)] //! A library and command line tool for identifying hashes. //! //! The main part of this crate is in the build script (`build.rs`). The build script uses the TOML //! files in `data/` to generate a list of regexes with their matching hash types and uses the //! fixtures to generate tests. //! //! The TOML files found in data are language agnostic and can be used to build similar libraries //! in other languages. //! //! # Examples //! //! Using the library: //! //! ``` //! assert_eq!(hash_data::parse("$1$42bad211$ums.eDtzK/1711rUkRsd31"), vec!["MD5(Unix)"]) //! ``` //! //! On the command line: //! //! ```sh //! $ hash-data '$1$42bad211$ums.eDtzK/1711rUkRsd31' //! MD5(Unix) //! ``` //! //! # Supported hash types: //! //! - Adler32 //! - Base64 //! - Blowfish //! - Eggdrop //! - OpenBSD //! - CRC //! - CRC-16, CRC-16-CCITT //! - CRC-32 //! - CRC-32B //! - CRC-96(ZIP) //! - DES //! - Oracle //! - Unix //! - Domain Cached Credentials //! - Domain Cached Credentials 2 //! - FCS //! - FCS-16 //! - FCS-32 //! - FNV //! - FNV-132 //! - FNV-164 //! - GHash //! - GHash-32-3 //! - GHash-32-5 //! - GOST R 34.11-94 //! - Haval //! - Haval-128 //! - Haval-160 //! - Haval-192 //! - Haval-224 //! - Haval-256 //! - Joaat //! - Keccak //! - Keccak-224 //! - Keccak-256 //! - LM //! - Lineage II C4 //! - Lotus Domino //! - MD2 //! - MD4 //! - MD5 //! - APR //! - Cisco PIX //! - IP.Board //! - Joomla //! - MyBB //! - Palshop //! - Unix //! - Wordpress //! - osCommerce //! - phpBB3 //! - MSSQL //! - MSSQL(2000) //! - MSSQL(2005) //! - MSSQL(2008) //! - MySQL //! - MySQL3.x //! - MySQL4.x //! - MySQL5.x //! - NTLM //! - RAdminv2.x //! - RIPEMD //! - RIPEMD-128 //! - RIPEMD-160 //! - RIPEMD-256 //! - RIPEMD-320 //! - SAM(LM_Hash:NT_Hash) //! - SHA //! - SHA-1(Django) //! - SHA-1(MaNGOS) //! - SHA-1(MaNGOS2) //! - SHA-224 //! - SHA-256 //! - SHA-256(Django) //! - SHA-256(Unix) //! - SHA-384 //! - SHA-384(Django) //! - SHA-512 //! - SHA-512(Drupal) //! - SHA-512(Unix) //! - SHA3-384 //! - SHA3-512 //! - SSHA-1 //! - Skein //! - Skein-256(128, 160, 224) //! - Skein-512(128, 160, 224, 256, 384) //! - Skein-1024(384, 512) //! - Snefru //! - Snefru-128 //! - Snefru-256 //! - Tiger //! - Tiger-128 //! - Tiger-160 //! - Tiger-192 //! - VNC //! - Whirlpool //! - XOR-32 include!(concat!(env!("OUT_DIR"), "/regexes.rs")); use regexes::REGEXES; /// Parses the hash and returns potential hash types. /// /// ``` /// assert_eq!(hash_data::parse("$1$42bad211$ums.eDtzK/1711rUkRsd31"), vec!["MD5(Unix)"]) /// ``` pub fn parse(input: &str) -> Vec<&str> { let mut matches = Vec::new(); if input.is_empty() { return matches; } matches = REGEXES.iter().fold(matches, |mut a, (r, v)| { if r.is_match(&input) { a.append(&mut v.clone()); }; a }); matches.sort(); matches } include!(concat!(env!("OUT_DIR"), "/fixture_tests.rs")); #[cfg(test)] mod tests { use super::*; #[test] fn test_empty_input() { assert_eq!(parse(&""), vec![] as Vec<&str>) } #[test] fn test_no_match() { assert_eq!(parse(&"not a matching hash"), vec![] as Vec<&str>) } }