Problem 3. (Encryption Program) Write a program called encrypt.py that accepts the public-key n (int) and e (int) as com
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Problem 3. (Encryption Program) Write a program called encrypt.py that accepts the public-key n (int) and e (int) as com
Problem 3. (Encryption Program) Write a program called encrypt.py that accepts the public-key n (int) and e (int) as command-line arguments and a message to encrypt from standard input, encrypts each character in the message, and writes its fixed-width binary representation to standard output. ¹A tuple is like a list, but is immutable. You create a tuple by enclosing comma-separated values within matched parentheses, eg, a = (1, 2, 3). If a is a tuple, a is the ith element in it. >_/workspace/project4 $ python3 encrypt.py 3599 1759 CS110 <ctrl-d> 00011000000001 Project 4 (RSA Cryptosystem) 11010100001010100011001010100011001110000110010111100100 Directions: . Accept public-key n (int) and e (int) as command-line arguments. . Get the number of bits per character (call it width) needed for encryption, ie, number of bits needed to encode n. • Accept message to encrypt from standard input. . For each character ce in message: Use the built-in function ord) to turn e into an integer z. Encrypt z. Write the encrypted value as a width-long binary string. . Write a newline character. 3/5
2 7 10 11 12 Simport rea import stdio import sys #Entry point. def main(): if_name_ main() _main__':