1# Java cleartext keysets example 2 3This example shows how to generate or load a cleartext keyset, obtain a 4primitive, and use the primitive to do crypto. 5 6WARNING: This is not recommended, consider protecting your keysets with a key 7management system. 8 9## Build and run 10 11### Bazel 12 13```shell 14git clone https://github.com/google/tink 15cd tink/examples/java_src 16bazel build ... 17``` 18 19Generate a cleartext keyset: 20 21```shell 22./bazel-bin/cleartextkeyset/cleartext_keyset_example generate aes128_gcm_test_keyset.json 23``` 24 25Encrypt a file with the resulting keyset: 26 27```shell 28echo "some data" > testdata.txt 29./bazel-bin/cleartextkeyset/cleartext_keyset_example encrypt \ 30 aes128_gcm_test_keyset.json \ 31 testdata.txt testdata.txt.encrypted 32``` 33 34Decrypt the file with the resulting keyset: 35 36```shell 37./bazel-bin/cleartextkeyset/cleartext_keyset_example decrypt \ 38 aes128_gcm_test_keyset.json \ 39 testdata.txt.encrypted testdata.txt.decrypted 40 41diff testdata.txt testdata.txt.decrypted 42``` 43