-
Notifications
You must be signed in to change notification settings - Fork 0
/
CryptoTester.java
34 lines (26 loc) · 948 Bytes
/
CryptoTester.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Based on the DevMedia article:
* https://www.devmedia.com.br/utilizando-criptografia-simetrica-em-java/31170
*
* @author Matheus Teles
*/
public class CryptoTester {
static String IV = "AAAAAAAAAAAAAAAA";
static String originalText = "Hello World!";
static String cryptographyKey = "1234567890123456";
public static void main(String[] args) throws Exception {
System.out.println("Original text: " + originalText);
Encrypter e = new Encrypter(IV, originalText, cryptographyKey);
byte[] encryptedText = e.encrypt();
System.out.println("Encrypted text: " + printEncrypted(encryptedText));
Decrypter d = new Decrypter(IV, encryptedText, cryptographyKey);
System.out.println("Decrypted text: " + d.decrypt());
}
private static String printEncrypted(byte[] encryptedText) {
String e = new String();
for(int i = 0; i < encryptedText.length; i++) {
e += encryptedText[i] + " ";
}
return e;
}
}