
Hi all, maybe one of you sees a difference, I sure don’t… The full code for this is below. When I call *Main> diffieH 23 16 20 13 and use the result in *Main> encipher "abc" 13 „nop" I get the letters to be expected. However, when I combine these into
start text p a b = encipher text (diffieH p a b)
*Main> start "abc" 23 16 20 „efg" the result changes. Any hints are most welcome. Thank you and regards Torsten
import Data.Char
diffieH p a b = (b ^ a) `mod` p
number2letter number = chr (number + 96) letter2number letter = (ord letter) - 96
start text p a b = encipher text (diffieH p a b)
encipher [] _ = [] encipher (b:rest) key = (number2letter (((letter2number b)+key) `mod` 26)) : (encipher rest key)

Hello Otto, Il 06 febbraio 2022 alle 19:00 Torsten Otto ha scritto:
When I call
*Main> diffieH 23 16 20 13
and use the result in
*Main> encipher "abc" 13 „nop"
I get the letters to be expected. However, when I combine these into
start text p a b = encipher text (diffieH p a b)
*Main> start "abc" 23 16 20 „efg"
the result changes.
You should always write top level signatures by hand in your code. What is the signature that you want for `diffieH`? This is the inferred one λ> :t diffieH diffieH :: (Integral a, Integral b) => a -> b -> a -> a
participants (2)
-
Francesco Ariis
-
Torsten Otto