diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-03-14 00:27:57 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-03-14 00:27:57 -0700 |
| commit | de1ba85346bd2af41ebb98f152bb769e2b630139 (patch) | |
| tree | f3d65d148e69e1b84ef17a953f1f0fa14286aae1 /other/java/client/src/test | |
| parent | e2e691d9c23d2b18b032f4d464ca0756c134ed87 (diff) | |
| download | seaweedfs-de1ba85346bd2af41ebb98f152bb769e2b630139.tar.xz seaweedfs-de1ba85346bd2af41ebb98f152bb769e2b630139.zip | |
HDFS support encrypted data storage
Diffstat (limited to 'other/java/client/src/test')
| -rw-r--r-- | other/java/client/src/test/java/seaweedfs/client/SeaweedCipherTest.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/other/java/client/src/test/java/seaweedfs/client/SeaweedCipherTest.java b/other/java/client/src/test/java/seaweedfs/client/SeaweedCipherTest.java new file mode 100644 index 000000000..7b5e53e19 --- /dev/null +++ b/other/java/client/src/test/java/seaweedfs/client/SeaweedCipherTest.java @@ -0,0 +1,42 @@ +package seaweedfs.client; + +import org.junit.Test; + +import java.util.Base64; + +import static seaweedfs.client.SeaweedCipher.decrypt; +import static seaweedfs.client.SeaweedCipher.encrypt; + +public class SeaweedCipherTest { + + @Test + public void testSameAsGoImplemnetation() throws Exception { + byte[] secretKey = "256-bit key for AES 256 GCM encr".getBytes(); + + String plainText = "Now we need to generate a 256-bit key for AES 256 GCM"; + + System.out.println("Original Text : " + plainText); + + byte[] cipherText = encrypt(plainText.getBytes(), secretKey); + System.out.println("Encrypted Text : " + Base64.getEncoder().encodeToString(cipherText)); + + byte[] decryptedText = decrypt(cipherText, secretKey); + System.out.println("DeCrypted Text : " + new String(decryptedText)); + } + + @Test + public void testEncryptDecrypt() throws Exception { + byte[] secretKey = SeaweedCipher.genCipherKey(); + + String plainText = "Now we need to generate a 256-bit key for AES 256 GCM"; + + System.out.println("Original Text : " + plainText); + + byte[] cipherText = encrypt(plainText.getBytes(), secretKey); + System.out.println("Encrypted Text : " + Base64.getEncoder().encodeToString(cipherText)); + + byte[] decryptedText = decrypt(cipherText, secretKey); + System.out.println("DeCrypted Text : " + new String(decryptedText)); + } + +} |
