-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd6e751
commit 33d85c0
Showing
13 changed files
with
346 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,9 @@ | ||
use crate::traits::ClassicHasher; | ||
use utils::byte_formatting::ByteFormat; | ||
|
||
pub struct BeltHash { | ||
pub input_format: ByteFormat, | ||
pub output_format: ByteFormat, | ||
} | ||
pub struct BeltHash {} | ||
|
||
impl Default for BeltHash { | ||
fn default() -> Self { | ||
Self { | ||
input_format: ByteFormat::Utf8, | ||
output_format: ByteFormat::Hex, | ||
} | ||
} | ||
} | ||
|
||
impl BeltHash { | ||
pub fn input(mut self, input: ByteFormat) -> Self { | ||
self.input_format = input; | ||
self | ||
Self {} | ||
} | ||
|
||
pub fn output(mut self, output: ByteFormat) -> Self { | ||
self.output_format = output; | ||
self | ||
} | ||
} | ||
|
||
impl ClassicHasher for BeltHash { | ||
fn hash(&self, bytes: &[u8]) -> Vec<u8> { | ||
todo!() | ||
} | ||
|
||
crate::hash_bytes_from_string! {} | ||
} | ||
|
||
crate::basic_hash_tests!( | ||
test1, | ||
BeltHash::default(), | ||
"INPUT", | ||
"OUTPUT"; | ||
); | ||
impl BeltHash {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,22 @@ | ||
use utils::byte_formatting::ByteFormat; | ||
|
||
use crate::traits::ClassicHasher; | ||
|
||
pub struct BsdChecksum { | ||
pub input_format: ByteFormat, | ||
pub output_format: ByteFormat, | ||
} | ||
pub struct BsdChecksum {} | ||
|
||
impl Default for BsdChecksum { | ||
fn default() -> Self { | ||
Self { | ||
input_format: ByteFormat::Hex, | ||
output_format: ByteFormat::Hex, | ||
} | ||
Self {} | ||
} | ||
} | ||
|
||
impl BsdChecksum {} | ||
|
||
impl ClassicHasher for BsdChecksum { | ||
fn hash(&self, bytes: &[u8]) -> Vec<u8> { | ||
let mut out = 0_u16; | ||
for byte in bytes { | ||
out = out.rotate_right(1); | ||
out = out.wrapping_add(*byte as u16); | ||
} | ||
out.to_le_bytes().to_vec() | ||
} | ||
|
||
crate::hash_bytes_from_string! {} | ||
} | ||
|
||
#[cfg(test)] | ||
mod bsd_tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test() { | ||
let mut hasher = BsdChecksum::default(); | ||
hasher.input_format = ByteFormat::Hex; | ||
hasher.output_format = ByteFormat::Hex; | ||
} | ||
} | ||
// impl ClassicHasher for BsdChecksum { | ||
// fn hash(&self, bytes: &[u8]) -> Vec<u8> { | ||
// let mut out = 0_u16; | ||
// for byte in bytes { | ||
// out = out.rotate_right(1); | ||
// out = out.wrapping_add(*byte as u16); | ||
// } | ||
// out.to_le_bytes().to_vec() | ||
// } | ||
|
||
// crate::hash_bytes_from_string! {} | ||
// } |
Oops, something went wrong.