Rust

Implementing Gravatars with Rust is relatively straightforward. Below you’ll find an example of how to do so.

Example Implementation

use sha2::{Digest, Sha256};

fn main() {
    let email = String::from("EMAIL_ADDRESS");
    let trimmed_email = email.trim();
    let mut hashed_email = Sha256::new();
    hashed_email.update(trimmed_email);
    println!("https://gravatar.com/avatar/{:X}", hashed_email.finalize());
}

Important Notes

Provide a link to gravatar.com/profile and let your users know how to edit their avatar and profile data.

Use of our free APIs is governed by these Guidelines for Responsible Use. Using our APIs to enable spam, phishing, or any types of fraud is not permitted.


Documentation is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

Last updated on