Jan-22-2017, 07:29 PM
Jan-23-2017, 04:35 AM
Keep each value of 'r' during iteration in a list for example then loop over the list and turn the each number into letter then prints them formated
Jan-23-2017, 12:00 PM
So in the beginning i use :
And what should i do for "chr" and "n" ?
So now i found not the letters i want, what should i do ?
r= (A*(ord(c)-65)+ B)%26 print(r , end=" | " )After I have the string bug
And what should i do for "chr" and "n" ?
So now i found not the letters i want, what should i do ?
Msg ="MATHS" def num (caractere): return ord (caractere)-65 def lettre (n): return chr('65') + 'n' for c in Msg : print (c,end="|") print() for c in Msg : print(num(c), end=" | ") print ('\n\n', 'le message est sous forme de chiffres') for c in Msg: print ( '\n\n','Maintenant veuillez entrer deux chiffres pour créer votre cles ') # Finir Cle print ('\n\n', 'soit la fonction affine a*x + b qui va vous permettre de créer votre cles ') A = 11 B = 7 for c in Msg: r= (A*(ord(c)-65)+ B)%26 + 65 print(lettre(r),end=" | ")
Jan-23-2017, 03:29 PM
Now the letters appears but they are strange : "An"
Why...
Why...
Jan-23-2017, 05:23 PM
Well,
for c in Msg: r= (A*(ord(c)-65)+ B)%26 print(lettre(r), end= " | " )evaluates for 'r' in this numbers
[74, 72, 73, 71, 88]
. When you substract 65 from each of them you get numbers between 9 and 23. The printable characters start from 32 which itself is space. See http://www.asciitable.com/ . These are not letters.Jan-24-2017, 11:54 AM

so now it's ok, but how have spaces between lines ?
Jan-24-2017, 06:19 PM
Someone know how to use the inverse of modulo on python ?
Now I have to create a decoder
A = a**-1 B = A*aso what should i do after ?
Now I have to create a decoder
Jan-24-2017, 09:32 PM
(Jan-24-2017, 11:54 AM)PYTHONEUR Wrote: [ -> ]Ah ok, sorry i m not very good in English
so now it's ok, but how have spaces between lines ?
Print a new line - print(). Or add aditional '\n' at the end of the previous print().
As acording to decription you have to revers the
(A*(ord(c)-65)+ B)%26
. Look at this: https://python-forum.io/Thread-What-is-a...Decryption
Jan-25-2017, 08:15 AM
Ok but after this :
"(a*(ord©-65)+ b)%26"
"62%)b +)56-)c(dro(*a("
I was thinking about reversing the affine function. Key(5;7)
a = 5, b = 7 12 = M
Imagine f(12) = 5(12) + 7 = 67
after this we search the rest of the division by :
67/26
we find r = 15 = P
So what should i do for reverse this
"(a*(ord©-65)+ b)%26"
"62%)b +)56-)c(dro(*a("
I was thinking about reversing the affine function. Key(5;7)
a = 5, b = 7 12 = M
Imagine f(12) = 5(12) + 7 = 67
after this we search the rest of the division by :
67/26
we find r = 15 = P
So what should i do for reverse this