forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXORCipherTest.java
More file actions
34 lines (25 loc) · 898 Bytes
/
XORCipherTest.java
File metadata and controls
34 lines (25 loc) · 898 Bytes
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
package com.thealgorithms.ciphers;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class XORCipherTest {
@Test
void xorEncryptTest() {
// given
String plaintext = "My t&xt th@t will be ençrypted...";
String key = "My ç&cret key!";
// when
String cipherText = XORCipher.encrypt(plaintext, key);
// then
assertEquals("000000b7815e1752111c601f450e48211500a1c206061ca6d35212150d4429570eed", cipherText);
}
@Test
void xorDecryptTest() {
// given
String cipherText = "000000b7815e1752111c601f450e48211500a1c206061ca6d35212150d4429570eed";
String key = "My ç&cret key!";
// when
String plainText = XORCipher.decrypt(cipherText, key);
// then
assertEquals("My t&xt th@t will be ençrypted...", plainText);
}
}