finished
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user