Implement challenge 33 Diffie-Hellman

This commit is contained in:
2022-08-31 19:30:34 -04:00
parent ddafb43934
commit 9e568ac97c
7 changed files with 91 additions and 19 deletions

12
src/rsa.rs Normal file
View File

@@ -0,0 +1,12 @@
pub fn expmod(base: u32, exp: u32, m: u32) -> u32 {
if exp == 0 {
return 1;
}
if exp % 2 == 0 {
let s = expmod(base, exp / 2, m);
(s * s) % m
} else {
(expmod(base, exp - 1, m) * base) % m
}
}