Hello! could someone help me with this problem? Thanks! Programming language: PYTHON If padding is necessary to reach a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Hello! could someone help me with this problem? Thanks! Programming language: PYTHON If padding is necessary to reach a

Post by answerhappygod »

Hello! could someone help me with this problem? Thanks!
Programming language: PYTHON
If padding is necessary to reach a certain block size,
you should pad with zeros on the right.
Recall that a cryptographically secure hash function
h with output length l can be
used to construct a block cipher as follows:
• split the message (file) to be encoded into blocks M1, M2, . .
. , MK of l bits;
• pad MK if necessary;
• choose an initialization vector IV and set M0 = IV ;
• to encrypt block Mi, compute h(K||Mi−1) and XOR it with Mi
(where K is the secret key).
Use the SHA-256 hash function to create an encryption algorithm
using the above approach. Note that the output of SHA-256 is always
256 bits long. Write a program which accepts a 256-bit
initialization vector and a secret key of arbitrary length, and
encrypts or decrypts a given file using the algorithm described
above. Taking IV = 111 . . . 1 and K = 0101 . . . 01, use the
program to encrypt the file gold plaintext.in.
- Given plaintext (gold_plaintext.in) : "This
is an example input file created specifically for the third
mandatory assignment in INF143A. If you are reading this, I wish
you a great Easter vacation, and good luck on the
assignment!"
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply