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
use url::Url; use ate::prelude::*; use ate::crypto::EncryptKey; pub fn chain_url(auth: Url, email: &String) -> Url { let hash = AteHash::from(email.clone()); let hex = hash.to_hex_string().to_lowercase(); let mut ret = auth.clone(); ret.set_path(format!("{}-{}", ret.path(), &hex[..4]).as_str()); ret } pub fn password_to_read_key(seed: &String, password: &String, repeat: i32) -> EncryptKey { let mut bytes = Vec::from(seed.as_bytes()); bytes.extend(Vec::from(password.as_bytes()).iter()); while bytes.len() < 1000 { bytes.push(0); } let hash = AteHash::from_bytes_sha3(password.as_bytes(), repeat); EncryptKey::from_seed_bytes(hash.to_bytes(), KeySize::Bit256) } pub fn conf_auth() -> ConfAte { let mut cfg_ate = ConfAte::default(); cfg_ate.configured_for(ConfiguredFor::BestSecurity); cfg_ate.log_format.meta = SerializationFormat::Json; cfg_ate.log_format.data = SerializationFormat::Json; cfg_ate.wire_format = SerializationFormat::Json; cfg_ate }