mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
ecaps2, error: Update to base64 0.5.
This commit is contained in:
parent
5d51dff9e6
commit
6a48a6bf00
3 changed files with 10 additions and 10 deletions
|
@ -6,7 +6,7 @@ authors = ["Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>"]
|
|||
[dependencies]
|
||||
minidom = "0.2.0"
|
||||
jid = "0.2.0"
|
||||
base64 = "0.4.1"
|
||||
base64 = "0.5.0"
|
||||
digest = "0.5.0"
|
||||
sha2 = "0.5.0"
|
||||
sha3 = "0.5.0"
|
||||
|
|
|
@ -118,25 +118,25 @@ pub fn hash_ecaps2(data: &[u8], algo: &str) -> String {
|
|||
let mut hasher = Sha256::default();
|
||||
hasher.input(data);
|
||||
let hash = hasher.result();
|
||||
base64::encode(&hash)
|
||||
base64::encode(&hash.as_slice())
|
||||
},
|
||||
"sha-512" => {
|
||||
let mut hasher = Sha512::default();
|
||||
hasher.input(data);
|
||||
let hash = hasher.result();
|
||||
base64::encode(&hash)
|
||||
base64::encode(&hash.as_slice())
|
||||
},
|
||||
"sha3-256" => {
|
||||
let mut hasher = Sha3_256::default();
|
||||
hasher.input(data);
|
||||
let hash = hasher.result();
|
||||
base64::encode(&hash)
|
||||
base64::encode(&hash.as_slice())
|
||||
},
|
||||
"sha3-512" => {
|
||||
let mut hasher = Sha3_512::default();
|
||||
hasher.input(data);
|
||||
let hash = hasher.result();
|
||||
base64::encode(&hash)
|
||||
base64::encode(&hash.as_slice())
|
||||
},
|
||||
"blake2b-256" => {
|
||||
let mut hasher = Blake2b::default();
|
||||
|
@ -438,12 +438,12 @@ mod tests {
|
|||
#[test]
|
||||
fn test_blake2b_512() {
|
||||
let hash = ecaps2::hash_ecaps2("abc".as_bytes(), "blake2b-512");
|
||||
let known_hash: [u8; 64] = [
|
||||
let known_hash: Vec<u8> = vec!(
|
||||
0xBA, 0x80, 0xA5, 0x3F, 0x98, 0x1C, 0x4D, 0x0D, 0x6A, 0x27, 0x97, 0xB6, 0x9F, 0x12, 0xF6, 0xE9,
|
||||
0x4C, 0x21, 0x2F, 0x14, 0x68, 0x5A, 0xC4, 0xB7, 0x4B, 0x12, 0xBB, 0x6F, 0xDB, 0xFF, 0xA2, 0xD1,
|
||||
0x7D, 0x87, 0xC5, 0x39, 0x2A, 0xAB, 0x79, 0x2D, 0xC2, 0x52, 0xD5, 0xDE, 0x45, 0x33, 0xCC, 0x95,
|
||||
0x18, 0xD3, 0x8A, 0xA8, 0xDB, 0xF1, 0x92, 0x5A, 0xB9, 0x23, 0x86, 0xED, 0xD4, 0x00, 0x99, 0x23,
|
||||
];
|
||||
);
|
||||
let known_hash = base64::encode(&known_hash);
|
||||
assert_eq!(hash, known_hash);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ pub enum Error {
|
|||
ParseError(&'static str),
|
||||
IoError(io::Error),
|
||||
XMLError(minidom::Error),
|
||||
Base64Error(base64::Base64Error),
|
||||
Base64Error(base64::DecodeError),
|
||||
ParseIntError(num::ParseIntError),
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ impl From<minidom::Error> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<base64::Base64Error> for Error {
|
||||
fn from(err: base64::Base64Error) -> Error {
|
||||
impl From<base64::DecodeError> for Error {
|
||||
fn from(err: base64::DecodeError) -> Error {
|
||||
Error::Base64Error(err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue