Name Date Size #Lines LOC

..--

BUILD.bazelH A D25-Apr-20251.2 KiB3934

HybridExample.javaH A D25-Apr-20253.2 KiB9348

README.mdH A D25-Apr-20251.1 KiB4733

hybrid_example_test.shH A D25-Apr-20254.2 KiB13373

hybrid_test_private_keyset.jsonH A D25-Apr-2025332 21

hybrid_test_public_keyset.jsonH A D25-Apr-2025282 21

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