Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an easier to read example in the "I want to encrypt data deterministically" docs page #571

Closed
fisadev opened this issue Jan 13, 2022 · 1 comment
Assignees

Comments

@fisadev
Copy link

fisadev commented Jan 13, 2022

This page of the docs is probably what most users will read first when trying to use the lib to encrypt data:
https://developers.google.com/tink/deterministic-encryption

The example there is nice and very useful to use as a command line tool, but I believe it's not that good as docs on how to use Tink, because the Tink-related code is buried within lots of extra code doing other unrelated (to the lib) stuff, like args parsing, file reading, error handling, etc. Around 90% of the code in the example is unrelated to Tink.

IMHO, I would still keep that example console tool, but before that I would include a far simpler example in which only encryption with Tink is done. Something like this:

from tink import JsonKeysetReader, cleartext_keyset_handle, daead

# prepare Tink, a keyset and a cipher
daead.register()
keyset_handle = cleartext_keyset_handle.read(JsonKeysetReader("maybe a keyset example here? is it too complex?"))
cipher = keyset_handle.primitive(daead.DeterministicAead)

# encrypt data:
input_data = "Hello world!"
associated_data = b""
encrypted_data = cipher.encrypt_deterministically(input_data, associated_data)

# decrypt data:
decrypted_data = cipher.decrypt_deterministically(encrypted_data, associated_data)
@kste kste assigned kste and unassigned thaidn and chuckx May 12, 2022
@kste
Copy link
Contributor

kste commented May 17, 2022

This is a very good point and we started adding simpler examples now, which also provide a more step-by-step explanation on what exactly is happening.

@kste kste closed this as completed May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants