Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
BUILD.bazel | H A D | 25-Apr-2025 | 1.2 KiB | 39 | 34 | |
HybridExample.java | H A D | 25-Apr-2025 | 3.2 KiB | 93 | 48 | |
README.md | H A D | 25-Apr-2025 | 1.1 KiB | 47 | 33 | |
hybrid_example_test.sh | H A D | 25-Apr-2025 | 4.2 KiB | 133 | 73 | |
hybrid_test_private_keyset.json | H A D | 25-Apr-2025 | 332 | 2 | 1 | |
hybrid_test_public_keyset.json | H A D | 25-Apr-2025 | 282 | 2 | 1 |
README.md
1# Java hybrid encryption example 2 3This example shows how to encrypt data with Tink using hybrid encryption. 4 5It demonstrates the basic steps of using Tink, namely loading key material, 6obtaining a primitive, and using the primitive to do crypto. 7 8The key material was generated with Tinkey: 9 10```shell 11tinkey create-keyset \ 12 --key-template DHKEM_X25519_HKDF_SHA256_HKDF_SHA256_AES_256_GCM \ 13 --out-format JSON --out hybrid_test_private_keyset.json 14 15tinkey create-public-keyset --in hybrid_test_private_keyset.json \ 16 --in-format JSON --out-format JSON --out hybrid_test_public_keyset.json 17``` 18 19## Build and run 20 21### Bazel 22 23```shell 24git clone https://github.com/google/tink 25cd tink/java_src/examples 26bazel build hybrid_example 27``` 28 29Encrypt a file: 30 31```shell 32echo "some data" > testdata.txt 33../bazel-bin/hybrid/hybrid_example encrypt \ 34 ../hybrid/hybrid_test_public_keyset.json \ 35 testdata.txt testdata.txt.encrypted 36``` 37 38Decrypt a file: 39 40```shell 41../bazel-bin/hybrid/hybrid_example decrypt \ 42 ../hybrid/hybrid_test_private_keyset.json \ 43 testdata.txt.encrypted testdata.txt.decrypted 44 45diff testdata.txt testdata.txt.decrypted 46``` 47