Create a function affineEncrypt(text, a, b) that returns the cipher text encrypted using key (a, b)....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create a function affineEncrypt(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 this is not the case, the function must raise a ValueError with message "The given key is invalid. The gcd(a,26) must be 1.". You may NOT use any built-in functions as part of your implementation, but you may use any functions you implemented in previous coding assignments. Please make sure to copy and paste them into this file, so that they are uploaded to CodePost when you submit your pa3.py file. []: def affineEncrypt (text, a, b): "encrypts the plaintext 'text', using an affine transformation key (a, b) INPUT: text plaintext as a string of letters a - integer satisfying ged(a, 26) = 1. Raises error if such is not the cas b-integer OUTPUT: The encrypted message as a string of characters pass Create a function affineEncrypt(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 this is not the case, the function must raise a ValueError with message "The given key is invalid. The gcd(a,26) must be 1.". You may NOT use any built-in functions as part of your implementation, but you may use any functions you implemented in previous coding assignments. Please make sure to copy and paste them into this file, so that they are uploaded to CodePost when you submit your pa3.py file. []: def affineEncrypt (text, a, b): "encrypts the plaintext 'text', using an affine transformation key (a, b) INPUT: text plaintext as a string of letters a - integer satisfying ged(a, 26) = 1. Raises error if such is not the cas b-integer OUTPUT: The encrypted message as a string of characters pass
Expert Answer:
Answer rating: 100% (QA)
def gcda b while b a b b a b return a def modinversea m for x in range1 m if a x m 1 return x return ... View the full answer
Related Book For
Statistics For Business And Economics
ISBN: 9780134506593
13th Edition
Authors: James T. McClave, P. George Benson, Terry Sincich
Posted Date:
Students also viewed these programming questions
-
b) Simplify the following expressions using logic laws & theorems. 1) F= (A+B)+C [2] ii) F=AB+BC ABC+ABCD. [4] Draw the circuit diagram for your result in ii) above. [3]
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
A trait determined by an X-linked dominant allele shows 100 percent penetrance and is expressed in 36 percent of the females in a population. Assuming that the population is in HardyWeinberg...
-
A uniformly solid sphere of mass M and radius R is fixed a distance h above a thin infinite sheet of mass density ps (mass/area). With what force does the sphere attract the sheet?
-
current year - end financial statements of Cabot Corporation follow. ( All sales were on credit; selected balance sheet amounts at December 3 1 of the prior year were inventory, $ 4 9 , 9 0 0 ; total...
-
Analyze the methanol oxidation data in Table B. 20 for multicollinearity. x1 X2 X3 X4 xs 0 454 8.8 3.90 1.30 1.1 474 8.2 3.68 1.16 4.2 524 7.0 2.78 1.25 94.2 503 7.4 2.27 1.57 20.7 493 7.6 2.40 1.55...
-
Harvey Hilgendorf was a licensed real estate broker acting as the agent of the Hagues in the sale of eighty acres of farmland. The Hagues, however, terminated Hilgendorfs agency before the expiration...
-
A stock's rate of return in year 1 is 0.1, in year 2 is 0.3, and in year 3 is 0.2. What is the stock annual arithmetric average return? A stock's rate of return in year 1 is 0.2, in year 2 is -0.1,...
-
A polling agency is investigating the voter support for a ballot measure in an upcoming city election. The agency will select a random sample of 500 voters from one region, Region A, of the city....
-
Wood-Work Manufacturing produced its first batch of the new Woodies (a coffee table that is believed to be one of the entity's best sellers). Their first batch of 8 Woodies in the 2021 financial year...
-
How may the acceptance of an offer to buy, sell, or lease goods be made?
-
Alan contracts with Pam to build a shopping mall on Pams land. Before construction begins, the city enacts a law that makes it illegal to build a mall in Pams area. Performance of this contract is a....
-
Marketshare, Inc., contracts with Ogle, a popular search engine, to use the searches conducted by Ogles users to compile data that will accurately pinpoint the users interests and provide advertisers...
-
Unless a contract provides otherwise, it is normally assumed to be a shipment contract. (True/False)
-
Trulov.com is an online dating site. Trulov allows subscribers to create profiles, browse other profiles, take a relationship test, use the sites computerized matching system, and exchange messages....
-
There are 100 lettered tiles in a board game. You chose the following tiles without looking: D, G, K, A, I. How many of the 100 tiles would you expect to be vowels?
-
Find the market equilibrium point for the following demand and supply functions. Demand: 2p = - q + 56 Supply: 3p - q = 34
-
The National Association of Realtors (NAR) reported the results of an April 2015 survey of home buyers. In a random sample of 1,971 residential properties purchased during the year, 414 were...
-
Researchers at the University of West Florida used regression analysis to build a model for predicting the outcome of presidential elections (Political Analysis, Vol. 17, 2009). The dependent...
-
The role of maintenance in energy saving in commercial refrigeration was the topic of an article in the Journal of Quality in Maintenance Engineering (Vol. 18, 2012). The authors provided the...
-
How does the firms WACC (with taxes) change with leverage?
-
Assume that Microsoft has no debt, a total market value of $2 trillion, and a marginal tax rate of 21%. If it permanently changes its leverage from no debt by taking on new debt in the amount of 13%...
-
In your view does transport add value in the supply chain?
Study smarter with the SolutionInn App