Skip to content

Instantly share code, notes, and snippets.

@phenomax
Last active December 16, 2017 20:55
Show Gist options
  • Save phenomax/e73b091147ae7c8b8761f06ed742693e to your computer and use it in GitHub Desktop.
Save phenomax/e73b091147ae7c8b8761f06ed742693e to your computer and use it in GitHub Desktop.
Simple IOTA Seed & Argon2 Hash Generator written in Rust
extern crate rand;
extern crate argon2rs;
use rand::distributions::{Range, IndependentSample};
use rand::OsRng;
use std::{thread, time};
fn main() {
let alphabet = ["9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S",
"T", "U", "V", "W", "X", "Y", "Z"];
let between = Range::new(0, alphabet.len());
// use cryptographically secure OsRng, which collects entropy from current operating system
let mut rng = OsRng::new().unwrap();
for i in 1..6 {
println!("Generating {}. IOTA seed...", i);
println!("");
let mut seed = String::new();
for _ in 0..80 {
seed += alphabet[between.ind_sample(&mut rng)];
}
println!("Seed");
println!("{}", seed);
println!("");
// print argon2 hash
println!("Argon2 Hash using salt 'cyka bylat'");
let salt = "cyka bylat";
let result = argon2rs::argon2i_simple(&seed, salt);
for byte in result.iter() {
print!("{:02x}", byte);
}
println!("");
println!("");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment