Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cryptography Problem
#21
If someone here can explain what should i do ?

Im lost...
Reply
#22
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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#23
So in the beginning i use : 

 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=" | ")
 

    
 
Reply
#24
Now the letters appears but they are strange : "An"

Why...
Reply
#25
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.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#26
Shocked Ah ok, sorry i m not very good in English

so now it's ok, but how have spaces between lines ?
Reply
#27
Someone know how to use the inverse of modulo on python ?

 
A = a**-1
B = A*a 
so what should i do after ?


 Now I have to create a decoder
Reply
#28
(Jan-24-2017, 11:54 AM)PYTHONEUR Wrote: Shocked 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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#29
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple Cryptography Capture the Flag DrEastwood 12 11,493 Oct-12-2016, 11:40 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020