This commit is contained in:
debris
2017-08-31 11:35:41 +02:00
parent f0e8abb07b
commit 7849fff41e
43 changed files with 130 additions and 95 deletions

View File

@@ -21,7 +21,8 @@ use std::{fs, time, mem};
use itertools::Itertools;
use rand::Rng;
use rand::os::OsRng;
use util::{H256, Hashable};
use hash::keccak;
use util::H256;
/// Providing current time in seconds
pub trait TimeProvider {
@@ -162,7 +163,7 @@ impl<T: TimeProvider> AuthCodes<T> {
return false;
}
let as_token = |code| format!("{}:{}", code, time).sha3();
let as_token = |code| keccak(format!("{}:{}", code, time));
// Check if it's the initial token.
if self.is_empty() {
@@ -231,12 +232,13 @@ mod tests {
use std::io::{Read, Write};
use std::{time, fs};
use std::cell::Cell;
use hash::keccak;
use util::{H256, Hashable};
use util::H256;
use super::*;
fn generate_hash(val: &str, time: u64) -> H256 {
format!("{}:{}", val, time).sha3()
keccak(format!("{}:{}", val, time))
}
#[test]