tree: db85b63903985d1b0b098219a4c960a50cbe5f17 [path history] [tgz]
  1. src/
  2. BUILD.bazel
  3. pom.xml
  4. README.md
examples/java_src/helloworld/README.md

Java Hello World

This is a command-line tool that can encrypt and decrypt small files with AES128-GCM.

It demonstrates the basic steps of using Tink, namely generating or loading key material, obtaining a primitive, and using the primitive to do crypto.

It also shows how to add a dependency on Tink using Maven. Please checkout the pom.xml file.

Moreover, since this app shares the same Bazel‘s WORKSPACE with Tink, its BUILD file can directly depend on Tink. Note that a copy of this app is hosted in the tink-examples repo, which uses its own Bazel’s WORKSAPCE, and has to add Tink as a dependency using Bazel's maven_jar rule.

Build and Run

Maven

git clone https://github.com/google/tink
cd tink/examples/java_src/
mvn package
echo foo > foo.txt
mvn exec:java -Dexec.args="encrypt --keyset test.cfg --in foo.txt --out bar.encrypted"
mvn exec:java -Dexec.args="decrypt --keyset test.cfg --in bar.encrypted --out foo2.txt"
cat foo2.txt

Bazel

git clone https://github.com/google/tink
cd tink/examples/java_src
bazel build ...
echo foo > foo.txt
./bazel-bin/helloworld/helloworld encrypt --keyset test.cfg --in foo.txt --out bar.encrypted
./bazel-bin/helloworld/helloworld decrypt --keyset test.cfg --in bar.encrypted --out foo2.txt
cat foo2.txt