Crates.io | email-address-extractor |
lib.rs | email-address-extractor |
version | 1.0.1 |
source | src |
created_at | 2024-06-07 22:14:18.937057 |
updated_at | 2024-06-09 14:57:01.769732 |
description | A blazingly fast command line tool written in pure safe Rust to automatically extract email addresses from files in a given path. |
homepage | |
repository | https://github.com/J-Schoepplenberg/email-address-extractor |
max_upload_size | |
id | 1265225 |
size | 243,467 |
A blazingly fast command line tool written in pure safe Rust to automatically extract email addresses from files in a given path.
cargo run --release /path/to/file
The tool writes the extracted email addresses to a plain text file called emails.txt
in the current directory.
Using the sample file provided by Have I Been Pwned, which contains 10 million records of typical breach data, we confirm that this tool extracts exactly 10 million email addresses successfully.
In the \sample
folder, multiple example files are available to showcase this tool's ability to extract email addresses from various file formats.
These sample files are provided:
This project is inspired by Have I Been Pwned and aims to help extract email addresses from data breaches, which are commonly in plain text file formats such as csv or sql. Utilizing a HashSet
, we ensure that the output has no duplicates.
Currently, there is no neat way in pure Rust to handle multiple file types with a one-size-fits-all solution. Here, we use magic numbers to identify the MIME type of the file, and then try to extract the textual content based on that knowledge. Not all file types use the same encoding, and some file formats are actually zip archives containing several different file types, such as xml.
To extract email addresses from text, we use the well-known regular expression \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b
which matches any email address sufficiently well. Formulating a perfect regular expression to validate an email address is actually not trivial. The subject is controversial. The only way to really validate an email address is to send an email to it, which we are obviously not going to do.