# AVN18ENC-Editorial

Practice

Contest

Author: Vipul Kumar

Editorialist: Vipul Kumar

EASY-MEDIUM

### PREREQUISITES:

Polynomial functions , XOR Operator etc.

### PROBLEM:

Find Encryption/Decryption depending on case

For 1, find Encryption and for 0 , find Decryption

Encryption rule :-

Step 1 :- f(x)=Ax+By+C

Step 2 :- f(x) XOR (index value)

### QUICK EXPLANATION:

For getting first level of encryption put ASCII of each character of message into the given function f(x)=Ax+By+C and obtain f(x) Eg. For 1st level of encryption

(value of A) * ( 1st character of message) + (value of B) * (1st character of message) + (value of C) = f(x)

For 2nd level of encryption XOR obtained f(x) with message’s index value
Obtained f(x) XOR 1 (index value i.e 1 in this case) = Encrypted code

For Decryption,

For 1st level of decryption

XOR obtained f(x) with message’s index value
Obtained f(x) XOR 1 (index value i.e 1 in this case) = Y

For 2nd level of decryption

(value of A) * ( 1st character of message) + (value of B) * (1st character of message) + (value of C) = Y

### AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.

Editorialist’s solution can be found here.

*AVHNCRY

1 Like