Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
779 B
4
Indexable
Never
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def gcd(a, h):
    temp = 0
    while(1):
        temp = a % h
        if (temp == 0):
            return h
        a = h
        h = temp
        
def find_relatively_prime_number(z):
    for i in range(1, z):
        if z % i == 0:
            break
    else:
        return z

def find_e(d, z):
    co_prime = gcd(d, z)
    if co_prime != 1:
        raise ValueError("d and z are not relatively prime")

    return (z // co_prime) % z

plain_text = str(input("Enter your text "))
plain_text = plain_text.capitalize()
numeric =alphabet.find(plain_text)+1
print(numeric)
p = int(input("Enter a prime number "))
q = int(input("Enter another prime number "))
n = p*q
z = (p-1)*(q-1)
d = find_relatively_prime_number(z)
e = find_e(d,z)

C =