Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
BUILD.bazel | D | 04-Jul-2025 | 1.1 KiB | 32 | 28 | |
CleartextKeysetExample.java | D | 04-Jul-2025 | 4.3 KiB | 108 | 55 | |
README.md | D | 04-Jul-2025 | 981 | 43 | 30 | |
cleartext_keyset_example_test.sh | D | 04-Jul-2025 | 2.8 KiB | 94 | 44 |
README.md
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/tink-crypto/tink-java 15cd examples 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