extern crate krypton; use krypton::hash::Hash; use krypton::hash::ripemd::{Ripemd160, Ripemd320}; #[test] fn ripemd160_test() { let mut ripemd160 = Ripemd160::new(); let mut output: [u8; 20] = [0; 20]; ripemd160.update(&[0x41; 32]); ripemd160.digest(&mut output); assert_eq!(output[..], [ 0x23, 0xae, 0x31, 0x71, 0x91, 0xab, 0xe2, 0xad, 0x44, 0xb1, 0xd4, 0x4d, 0x81, 0x29, 0x42, 0xe0, 0xef, 0xd0, 0x0a, 0xf3][..]); ripemd160.update(&[0x41; 30]); ripemd160.digest(&mut output); assert_eq!(output[..], [ 0x76, 0x18, 0x35, 0xac, 0x1d, 0x80, 0xf1, 0xca, 0x71, 0x0e, 0x55, 0x1c, 0xed, 0x9b, 0xee, 0xef, 0x7d, 0x37, 0x28, 0x2f][..]); ripemd160.reset(); ripemd160.digest(&mut output); assert_eq!(output[..], [ 0x9c, 0x11, 0x85, 0xa5, 0xc5, 0xe9, 0xfc, 0x54, 0x61, 0x28, 0x08, 0x97, 0x7e, 0xe8, 0xf5, 0x48, 0xb2, 0x25, 0x8d, 0x31][..]); } #[test] fn ripemd320_test() { let mut ripemd320 = Ripemd320::new(); let mut output: [u8; 40] = [0; 40]; ripemd320.update(&[0x41; 32]); ripemd320.digest(&mut output); assert_eq!(output[..], [ 0x8f, 0xee, 0x26, 0x12, 0x19, 0x5c, 0x05, 0x2f, 0x0e, 0x4f, 0x38, 0x33, 0xb0, 0x53, 0xf0, 0xf2, 0xf3, 0x22, 0xc2, 0x25, 0xd0, 0xdd, 0xc2, 0x4b, 0xdd, 0x8c, 0x2d, 0x7b, 0x07, 0x60, 0x25, 0xe8, 0x7b, 0x53, 0x87, 0xca, 0xd3, 0xbc, 0xa9, 0xaf][..]); ripemd320.update(&[0x41; 30]); ripemd320.digest(&mut output); assert_eq!(output[..], [ 0x09, 0x96, 0x14, 0xa9, 0xa8, 0xe0, 0x7c, 0x3d, 0x25, 0xe6, 0x3e, 0x39, 0x25, 0x45, 0xbc, 0x8f, 0x3c, 0x79, 0xca, 0xf4, 0x0c, 0x77, 0xef, 0xc6, 0x5f, 0x3d, 0x5e, 0x97, 0x7f, 0x2d, 0x03, 0x62, 0x15, 0x11, 0x09, 0x24, 0x0a, 0xae, 0xf5, 0x67][..]); ripemd320.reset(); ripemd320.digest(&mut output); assert_eq!(output[..], [ 0x22, 0xd6, 0x5d, 0x56, 0x61, 0x53, 0x6c, 0xdc, 0x75, 0xc1, 0xfd, 0xf5, 0xc6, 0xde, 0x7b, 0x41, 0xb9, 0xf2, 0x73, 0x25, 0xeb, 0xc6, 0x1e, 0x85, 0x57, 0x17, 0x7d, 0x70, 0x5a, 0x0e, 0xc8, 0x80, 0x15, 0x1c, 0x3a, 0x32, 0xa0, 0x08, 0x99, 0xb8][..]); }