Browse Source

Implement `encrypt`

DricomDragon 5 years ago
parent
commit
f61fa12339
1 changed files with 6 additions and 0 deletions
  1. 6 0
      tp/rsa/main.hs

+ 6 - 0
tp/rsa/main.hs

@@ -78,3 +78,9 @@ expMod x k n =
 			then expMod (mod ((mod x n) * (mod x n)) n) (div k 2) n
 			else (mod x n) * expMod ((mod x n) * (mod x n)) (div k 2) n
 
+encrypt::Int -> Int -> Int -> String -> Message
+encrypt e n bsize smsg =
+	let msg = stringToMessage smsg in
+	let bmsg = makeBlocks bsize msg in
+	map (\m -> expMod m e n) bmsg
+