This example shows how to generate or load a cleartext keyset, obtain a primitive, and use the primitive to do crypto.
WARNING: this is not recommended, consider protecting your keysets with a key management system.
$ git clone https://github.com/google/tink $ cd tink/python/examples $ bazel build ...
You can generate a cleartext keyset:
$ ./bazel-bin/cleartext_keyset/cleartext_keyset --mode generate \ --keyset_path aes128_gcm_test_keyset.json
You can then encrypt a file with the resulting keyset:
$ echo "some data" > testdata.txt $ ./bazel-bin/cleartext_keyset/cleartext_keyset --mode encrypt \ --keyset_path aes128_gcm_test_keyset.json \ --input_path testdata.txt --output_path testdata.txt.encrypted
Or decrypt a file with:
$ ./bazel-bin/cleartext_keyset/cleartext_keyset --mode decrypt \ --keyset_path aes128_gcm_test_keyset.json \ --input_path testdata.txt.encrypted --output_path testdata.txt.decrypted $ diff testdata.txt testdata.txt.decrypted