Question: PLEASE HELP ME FIX THIS CODES FOR THIS PROBLEMSProblem 1 : Complete the function affine _ encrypt ( text , a , b ) that

PLEASE HELP ME FIX THIS CODES FOR THIS PROBLEMSProblem 1:
Complete the function affine_encrypt(text, a, b) that returns the cipher text encrypted
using key (a,b). You must verify that the gcd(a,26)=1 before making the encryption. If
gcd(a,26)1, the function must raise a ValueError exception with message "The
given key is invalid." .
def affine_encrypt(text,a,b :
"""
encrypts the plaintext 'text', using an affine transformation key (a,b
:param: text - str type; plaintext as a string of letters
:param: a - int type; integer satisfying gcd(a,26)=1
nvert/htm/OneDrive/Documents/Teaching/1. Materials/2024/CECS 229/2. Programming Assignments/PA %233/CECS 229 Progra...
CECS 229 Programming Assignment #3
:param: b - int type; shift value
: raise: ValueError if gcd(a,26) is not 1.
:return: str type; the encrypted message as string of uppercase letters
n nn
# FIXME: raise an error if the gcd(a,26) is not 1
cipher ="
for letter in text:
if letter.isalpha():
# FIXME: Use
util.py to initialize 'num' to be
# the integer corresponding to the current letter
num = None
# FIXME: Encrypt the current 'num' using the
# affine transformation with key (a,b).
# Store the result in cipher_digits.
cipher_digits = "None"
if len(cipher_digits)==1 :
# FIXME: If the cipherdigit is 0-9,
# prepend the string with a
# to make it a two-digit number
cipher_digits = None
# FIXME: Use
util.py to append to the cipher the ENCRYPTED letter
# corresponding to the current cipher digits
cipher += 'None"
return cipher
 PLEASE HELP ME FIX THIS CODES FOR THIS PROBLEMSProblem 1: Complete

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!