Matrix in cryptography | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Matrix in cryptography

This code is able to encrypt a plaintext but gives a different plaintext after decryption. Help me identify the errors in the code. https://code.sololearn.com/c0DsXQrAiXAw/?ref=app

26th Mar 2023, 2:44 PM
Believe Gagbe
3 Answers
+ 1
Here is my result after reading about affine cipher. I used a custom alphabet list to extend the characters to include upper and lowercase letters, punctuations and numbers. You can possibly use the entire ascii codelist, but that would probably be overkill.. There are certain constraints for the keys a and b in affine cipher. That's the important part. The formula for getting the multiplicative inverse I got from Stackoverflow. The keys are randomly determined every time. You can choose a certain pair and use that instead for repeatable cipher code values... As for turning it to a numpy matrix, maybe you could explain how it's supposed to work? I'm not sure I can follow your code.. https://code.sololearn.com/chXd66e5OwdJ/?ref=app
27th Mar 2023, 5:46 AM
Bob_Li
Bob_Li - avatar
+ 1
Believe Gagbe perhaps you're doing something like this? It uses numpy, but it is using it differently. https://justcryptography.com/hill-cipher/
27th Mar 2023, 6:49 AM
Bob_Li
Bob_Li - avatar
+ 1
Great, i will take a close look a your answers.
27th Mar 2023, 7:11 AM
Believe Gagbe