-
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
22e67bf
commit ef5348a
Showing
4 changed files
with
116 additions
and
103 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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use hashers::{ | ||
adler::Adler32, | ||
errors::HasherError, | ||
fxhash::{FxHash, FxHashVariant}, | ||
traits::StatefulHasher, | ||
}; | ||
use utils::byte_formatting::ByteFormat; | ||
|
||
use super::HasherFrame; | ||
|
||
pub struct FxHashFrame { | ||
input_format: ByteFormat, | ||
output_format: ByteFormat, | ||
variant: FxHashVariant, | ||
} | ||
|
||
impl Default for FxHashFrame { | ||
fn default() -> Self { | ||
Self { | ||
input_format: ByteFormat::Utf8, | ||
output_format: ByteFormat::Hex, | ||
variant: FxHashVariant::W64, | ||
} | ||
} | ||
} | ||
|
||
impl FxHashFrame {} | ||
|
||
impl HasherFrame for FxHashFrame { | ||
fn ui(&mut self, ui: &mut egui::Ui, _errors: &mut String) { | ||
ui.hyperlink_to( | ||
"see the code", | ||
"https://github.com/SymmetricChaos/crypto-gui/blob/master/hashers/src/fxhash.rs", | ||
); | ||
ui.add_space(8.0); | ||
|
||
ui.add_space(16.0); | ||
ui.horizontal(|ui| { | ||
ui.selectable_value(&mut self.variant, FxHashVariant::W32, "32-bit"); | ||
ui.selectable_value(&mut self.variant, FxHashVariant::W64, "64-bit"); | ||
}); | ||
|
||
ui.label("<<<EXPLANATION OF HASH FUNCTION CODE>>>"); | ||
|
||
ui.add_space(16.0); | ||
} | ||
|
||
fn hash_string(&self, text: &str) -> Result<String, HasherError> { | ||
let bytes = self | ||
.input_format | ||
.text_to_bytes(text) | ||
.map_err(|_| hashers::errors::HasherError::general("byte format error"))?; | ||
|
||
let h = FxHash::init(self.variant).hash(&bytes); | ||
|
||
Ok(self.output_format.byte_slice_to_text(&h)) | ||
} | ||
} |
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