aboutsummaryrefslogtreecommitdiff
path: root/rust/src/implementation/passwordmaker/helperthread/profile_to_domain.rs
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2022-10-10 21:30:02 +0200
committerAndreas Grois <andi@grois.info>2022-10-10 21:37:15 +0200
commite4ad766315879e1ff05bb111229f073f8f0ed68e (patch)
tree4b043ff47c78b2c00c80c94ebda622c32c8b6d3d /rust/src/implementation/passwordmaker/helperthread/profile_to_domain.rs
PassFish: Initial Commit
Well, that's a lie. But nobody needs to see all the iterations I decided to sweep under the rug. That said, I think the repo is, while not clean, clean enough now, to not be embarrassed by uploading it to github.
Diffstat (limited to 'rust/src/implementation/passwordmaker/helperthread/profile_to_domain.rs')
-rw-r--r--rust/src/implementation/passwordmaker/helperthread/profile_to_domain.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/rust/src/implementation/passwordmaker/helperthread/profile_to_domain.rs b/rust/src/implementation/passwordmaker/helperthread/profile_to_domain.rs
new file mode 100644
index 0000000..152ba8f
--- /dev/null
+++ b/rust/src/implementation/passwordmaker/helperthread/profile_to_domain.rs
@@ -0,0 +1,46 @@
+/// This whole module may look dumb, but that might change, once the public interface of passwordmaker_rs starts to deviate from the saved data.
+
+use passwordmaker_rs::{HashAlgorithm,UseLeetWhenGenerating,LeetLevel};
+
+pub(super) fn convert_hash_algorithm(stored_algo : &crate::implementation::profiles::HashAlgorithm) -> HashAlgorithm {
+ use crate::implementation::profiles::HashAlgorithm as PHashAlgorithm;
+ match stored_algo {
+ PHashAlgorithm::Md4 => HashAlgorithm::Md4,
+ PHashAlgorithm::HmacMd4 => HashAlgorithm::HmacMd4,
+ PHashAlgorithm::Md5 => HashAlgorithm::Md5,
+ PHashAlgorithm::Md5Version06 => HashAlgorithm::Md5Version06,
+ PHashAlgorithm::HmacMd5 => HashAlgorithm::HmacMd5,
+ PHashAlgorithm::HmacMd5Version06 => HashAlgorithm::HmacMd5Version06,
+ PHashAlgorithm::Sha1 => HashAlgorithm::Sha1,
+ PHashAlgorithm::HmacSha1 => HashAlgorithm::HmacSha1,
+ PHashAlgorithm::Sha256 => HashAlgorithm::Sha256,
+ PHashAlgorithm::HmacSha256 => HashAlgorithm::HmacSha256,
+ PHashAlgorithm::Ripemd160 => HashAlgorithm::Ripemd160,
+ PHashAlgorithm::HmacRipemd160 => HashAlgorithm::HmacRipemd160,
+ }
+}
+
+pub(super) fn convert_leet(stored_leet : &crate::implementation::profiles::UseLeetWhenGenerating) -> UseLeetWhenGenerating {
+ use crate::implementation::profiles::UseLeetWhenGenerating as PUseLeetWhenGenerating;
+ match stored_leet {
+ PUseLeetWhenGenerating::NotAtAll => UseLeetWhenGenerating::NotAtAll,
+ PUseLeetWhenGenerating::Before { level } => UseLeetWhenGenerating::Before { level: convert_leet_level(level) },
+ PUseLeetWhenGenerating::After { level } => UseLeetWhenGenerating::After { level: convert_leet_level(level) },
+ PUseLeetWhenGenerating::BeforeAndAfter { level } => UseLeetWhenGenerating::BeforeAndAfter { level: convert_leet_level(level) },
+ }
+}
+
+fn convert_leet_level(stored_level : &crate::implementation::profiles::LeetLevel) -> LeetLevel {
+ use crate::implementation::profiles::LeetLevel as PLeetLevel;
+ match stored_level {
+ PLeetLevel::One => LeetLevel::One,
+ PLeetLevel::Two => LeetLevel::Two,
+ PLeetLevel::Three => LeetLevel::Three,
+ PLeetLevel::Four => LeetLevel::Four,
+ PLeetLevel::Five => LeetLevel::Five,
+ PLeetLevel::Six => LeetLevel::Six,
+ PLeetLevel::Seven => LeetLevel::Seven,
+ PLeetLevel::Eight => LeetLevel::Eight,
+ PLeetLevel::Nine => LeetLevel::Nine,
+ }
+} \ No newline at end of file