A simple program to encode and decode matrix ciphered text.
First of all import the dependency and repository:
<repository>
<id>PauMAVen</id>
<url>https://raw.githubusercontent.com/PauMAVA/PauMAVen/master</url>
</repository>
<dependency>
<groupId>me.PauMAVA</groupId>
<artifactId>MatrixCipher</artifactId>
<version>0.1.003</version>
</dependency>
String encrypted = MatrixCipherTools.encrypt("Hello world, my name is PauMAVA");
// Encrypted text: Hl ly eormealo mPVw,a A dnsM! iuA
String decrypted = MatrixCipherTools.decrypt("Hl ly eormealo mPVw,a A dnsM! iuA");
// Decrypted text: Hello world, my name is PauMAVA
First of all you need to understand the two methods of iterating a matrix that this library uses.
| | - | - | - | - | > |
---|---|---|---|---|---|
| | - | - | - | - | > |
| | - | - | - | - | > |
| | - | - | - | - | > |
| | - | - | - | - | > |
V | - | - | - | - | > |
/ | ^ | ^ | ^ | ^ | ^ |
---|---|---|---|---|---|
/ | / | / | / | / | ^ |
/ | / | / | / | / | ^ |
/ | / | / | / | / | ^ |
/ | / | / | / | / | ^ |
/ | / | / | / | / | / |
The text to be encrypted is written diagonally in a Character matrix:
H | l | l | y | i | |
---|---|---|---|---|---|
e | o | r | m | u | |
l | o | e | a | A | |
w | , | m | P | V | |
d | a | A | |||
n | s | M |
Then the text is read in a natural reading order (left to right and up to down).
The text to be decrypted is written naturally in a Character matrix. Then the text is read diagonally.
By enabling advanced mode an extra step will be added to the encryption/decryption process.
- Every
char
will be converted to anint
. - A number corresponding to the multiplication of the coordinates in the matrix of the
char
will be added to theint
code in a circular range between 48 and 125. - The
int
will be converted to achar
.
To use advanced encryption/decryption:
MatrixCipherTools.encrypt("Your text", true);
MatrixCipherTools.decrypt("Your text", true);