{"id":21354948,"url":"https://github.com/salrashid123/tink_samples","last_synced_at":"2025-07-12T22:32:24.186Z","repository":{"id":91310200,"uuid":"305696598","full_name":"salrashid123/tink_samples","owner":"salrashid123","description":"Simple Examples of using Tink Encryption library in Golang","archived":false,"fork":false,"pushed_at":"2024-04-22T19:58:11.000Z","size":114,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-22T21:05:05.903Z","etag":null,"topics":["aes","cryptography","encryption","golang","hmac","tink-crypto"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salrashid123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-10-20T12:13:18.000Z","updated_at":"2024-04-22T19:58:15.000Z","dependencies_parsed_at":"2024-04-22T20:59:44.553Z","dependency_job_id":"48d5e3c3-331f-42d5-ab0b-fa6c4bb519a1","html_url":"https://github.com/salrashid123/tink_samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salrashid123%2Ftink_samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salrashid123%2Ftink_samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salrashid123%2Ftink_samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salrashid123%2Ftink_samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salrashid123","download_url":"https://codeload.github.com/salrashid123/tink_samples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225839601,"owners_count":17532308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aes","cryptography","encryption","golang","hmac","tink-crypto"],"created_at":"2024-11-22T04:15:24.586Z","updated_at":"2024-11-22T04:15:25.057Z","avatar_url":"https://github.com/salrashid123.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Simple Examples of using Tink Encryption library in Golang\n\nJust a scratchpad for [Tink](https://github.com/google/tink) examples i used (and will use again).\n\nThis is just for my reference...the official examples are [here](https://github.com/google/tink/blob/master/docs/GOLANG-HOWTO.md)\n\nsome more uses/references w/ Tink:\n\n* [End-to-End Stream encryption with gsutil and TINK](https://github.com/salrashid123/gcs_stream_enc)\n* [Message Payload Encryption in Google Cloud Pub/Sub](https://github.com/salrashid123/gcp_pubsub_message_encryption)\n* [Message Encryption with Dataflow PubSub Stream Processing](https://github.com/salrashid123/dataflow_pubsub_message_encryption)\n\n---\n\n- `client/`:  Encrypt/Decrypt string using the b64 encoded form of the keyset protobuf of `aead.AES256GCMKeyTemplate()` type.\n\n```json\n{\n  \"primaryKeyId\": 1791408185,\n  \"key\": [\n    {\n      \"keyData\": {\n        \"typeUrl\": \"type.googleapis.com/google.crypto.tink.AesGcmKey\",\n        \"value\": \"GiAO06HMApt+/970XhBkkbKEqfmtCgKvimBCqih+XVaguA==\",\n        \"keyMaterialType\": \"SYMMETRIC\"\n      },\n      \"status\": \"ENABLED\",\n      \"keyId\": 1791408185,\n      \"outputPrefixType\": \"TINK\"\n    }\n  ]\n}\n```\n\n- `client_siv/`:  Encrypt/Decrypt using AES-SIV.\n\n```json\n {\n\t\"primaryKeyId\": 2596996162,\n\t\"key\": [\n\t\t{\n\t\t\t\"keyData\": {\n\t\t\t\t\"typeUrl\": \"type.googleapis.com/google.crypto.tink.AesSivKey\",\n\t\t\t\t\"value\": \"EkCghIBMZApqHfym2jqG7xPQ+b1T1TVY02Yc+fESzKSGeHJGqUqTgWIaTMBqogbrDv3uM8ho9C9aUHveT/1Wxl6x\",\n\t\t\t\t\"keyMaterialType\": \"SYMMETRIC\"\n\t\t\t},\n\t\t\t\"status\": \"ENABLED\",\n\t\t\t\"keyId\": 2596996162,\n\t\t\t\"outputPrefixType\": \"RAW\"\n\t\t}\n\t]\n}\n```\n\n\n- `client_kms`: Encrypt/Decrypt using Envelope encryption where the KEK is in KMS.  THis encrypts the KeySet directly with  a KMS key\n\nEncrypted (`google.crypto.tink.AesGcmKey`).  Use this to encrypt multiple messages and save the encrypted key outside of the ciphertext storage\n\n```json\n {\n\t\"encryptedKeyset\": \"CiUAmT+VVR1i/HwmBQVSqROqM5gpO6wUmt+LKRqgY9VzbdG0WfHuEpUBACsKZVL5EieNkMUQTxjy2QhBAOpir5Z5o98sccXf1LlyTE5/dTzvunhdJym62HO0KF1OQi36UZxuxIm1XyknfEVJOKOksgyLfFUY7IWlJsFwGuzOhugsJEXPSYPMj0WOEYDUogH5WDJY7aP4KgubuaDUD7fRNwHZejR7L+Yz4r+9IyIRrY9YiPCF0tDfPAmtUI6ffFY=\",\n\t\"keysetInfo\": {\n\t\t\"primaryKeyId\": 4015179016,\n\t\t\"keyInfo\": [\n\t\t\t{\n\t\t\t\t\"typeUrl\": \"type.googleapis.com/google.crypto.tink.AesGcmKey\",\n\t\t\t\t\"status\": \"ENABLED\",\n\t\t\t\t\"keyId\": 4015179016,\n\t\t\t\t\"outputPrefixType\": \"TINK\"\n\t\t\t}\n\t\t]\n\t}\n}\n```\n\n- `client_kms_envelope`: (`google.crypto.tink.KmsEnvelopeAeadKey`)\n\n  Please see [https://github.com/google/tink/issues/509](https://github.com/google/tink/issues/509)\n\n\n```json\n {\n\t\"encryptedKeyset\": \"AWesY4MAAAB0CiUAmT+VVZjhoN5ImPXgebCOA5lut6L30orwoH6EU/27ze03L3urEksAKwplUpHAvT1TalZrFBmaDrsxmwU4pnUJfvQ1yunojPw/0vLQPvyEfvRMy99TKK4HRu4DVMSFiLR7GVMoPUD06/NPzU1o5e+D84E/30lDyYrScC5LgwgYm0q8YI/oy/SBCKju8SLaC8FY6HCOxIykF+YGcgZM5ohjtpYQe0AHWTkDQ5y0IoAbIacdM2iplhxZf8qUGfWF1M2s6WfKIukcn7CCWejxVUa8HrcaQ71N6Wo8B3TNFNA2fnyIld7Pz3KJFTz/jQqFcqhzzaoTCpQr00P0SCmecQRqYnXtMnvmBVWazWRH92FBlpuTvAgr+kREbKCb5lgfsvjhLFrHiHywY2ml2sEtkUGoFjkM5ppdoJxrtaTzhX7o1Okdqnq6yojHa6h7ezxaGjbIAP7Ls+WdaHLdRzOmG3EKLp1YXd/8nNKC/ahj75QaO8+dGXjYjmE4uo8LWF1ghLsC7w==\",\n\t\"keysetInfo\": {\n\t\t\"primaryKeyId\": 1739350915,\n\t\t\"keyInfo\": [\n\t\t\t{\n\t\t\t\t\"typeUrl\": \"type.googleapis.com/google.crypto.tink.KmsEnvelopeAeadKey\",\n\t\t\t\t\"status\": \"ENABLED\",\n\t\t\t\t\"keyId\": 1739350915,\n\t\t\t\t\"outputPrefixType\": \"TINK\"\n\t\t\t}\n\t\t]\n\t}\n}\n```\n\n- `client_stream`: Encrypt/Decrypt using AEAD Stream\n\n- `client_stream_gcs`: Encrypt/Decrypt using AEAD Stream.  Source-\u003eDestination are objects in GCS\n   GCS(stream) -\u003e Tink(stream encrypt) -\u003e GCS(stream)\n\n- `client_hybrid`:  Hybrid encryption (eg. encrypt symmetric key with asymmetric key)\n\n```json\n {\n\t\"primaryKeyId\": 569289530,\n\t\"key\": [\n\t\t{\n\t\t\t\"keyData\": {\n\t\t\t\t\"typeUrl\": \"type.googleapis.com/google.crypto.tink.EciesAeadHkdfPublicKey\",\n\t\t\t\t\"value\": \"ElwKBAgCEAMSUhJQCjh0eXBlLmdvb2dsZWFwaXMuY29tL2dvb2dsZS5jcnlwdG8udGluay5BZXNDdHJIbWFjQWVhZEtleRISCgYKAggQEBASCAoECAMQEBAgGAEYARogK1ZsW8pVVMIPwzhm4thj0ZjSk+lpWluMIsLwm32kF9MiIEpyowCqmanFl7GuppVZVvKflZwDV1yNHhgrCxlwQsoJ\",\n\t\t\t\t\"keyMaterialType\": \"ASYMMETRIC_PUBLIC\"\n\t\t\t},\n\t\t\t\"status\": \"ENABLED\",\n\t\t\t\"keyId\": 569289530,\n\t\t\t\"outputPrefixType\": \"TINK\"\n\t\t}\n\t]\n}\n```\n\n- `client_signature`: DigitalSignature using EC\n\n```json\n {\n\t\"primaryKeyId\": 2190705367,\n\t\"key\": [\n\t\t{\n\t\t\t\"keyData\": {\n\t\t\t\t\"typeUrl\": \"type.googleapis.com/google.crypto.tink.EcdsaPublicKey\",\n\t\t\t\t\"value\": \"EgYIAxACGAIaIEG8Cfq3ZyZEgK/hIEqbzI1y2N5aDZewlFeDgV0Kun5mIiCp+AxtjQxscdvpx4nXoPwtQy5ue+EFATNY2GTF77BV7w==\",\n\t\t\t\t\"keyMaterialType\": \"ASYMMETRIC_PUBLIC\"\n\t\t\t},\n\t\t\t\"status\": \"ENABLED\",\n\t\t\t\"keyId\": 2190705367,\n\t\t\t\"outputPrefixType\": \"RAW\"\n\t\t}\n\t]\n}\n```\n\n- `python_tink`: Simple AEAD for python\n\n- `external_aes_gcm`: import and use an external AES GCM Key.\n\n- `external_kms`: import and use an external AES GCM Key which is encrypted with KMS `EncryptedKeySet`.\n\n- `external_hmac`: import and use an external HMAC Key which is encrypted with KMS `EncryptedKeySet`.\n\n- `aes_key_convert/`: Encrypt with TINK and decrypt with crypto.aes","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalrashid123%2Ftink_samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalrashid123%2Ftink_samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalrashid123%2Ftink_samples/lists"}