Git Product home page Git Product logo

gcloud-kms-scripts's Introduction

Google Cloud Platform KMS encryption utilities

A collection of scripts here to help interact with Google's Cloud Key Management Service, without too many layers of indirection.

The utilities

  • kms-encrypt - Encrypt a plaintext string to a secret
  • kms-decrypt - Decrypt a secret to a plaintext string

Each script can be invoked with -h to see it's usage.

Examples

Encrypt

kms-encrypt -r "projects/[PROJECT_ID]/locations/[LOCATION]/keyRings/[keyring_name]/cryptoKeys/[key_name]"

kms-encrypt will ask for a plaintext string to encrypt and yield the encrypted result:

Please enter a plaintext string to encrypt
> test
CiQAUqQA4o9w4O3ovBCcj…

Alternatively, you can pass plaintext string to encrypt into kms-encrypt:

kms-encrypt -r "projects/[PROJECT_ID]/locations/[LOCATION]/keyRings/[keyring_name]/cryptoKeys/[key_name]" -p test
# "CiQAUqQA4o9w4O3ovBCcj…"
echo -n test | kms-encrypt -r "projects/[PROJECT_ID]/locations/[LOCATION]/keyRings/[keyring_name]/cryptoKeys/[key_name]"
# "CiQAUqQA4o9w4O3ovBCcj…"

Decrypt

kms-decrypt -r "projects/[PROJECT_ID]/locations/[LOCATION]/keyRings/[keyring_name]/cryptoKeys/[key_name]"

kms-decrypt will ask for a secret to decrypt and yield the plaintext result:

Please enter a secret to decrypt
> CiQAUqQA4o9w4O3ovBCcj…
test

Alternatively, you can pass secret to decrypt into kms-decrypt:

kms-decrypt -r "projects/[PROJECT_ID]/locations/[LOCATION]/keyRings/[keyring_name]/cryptoKeys/[key_name]" -s "CiQAUqQA4o9w4O3ovBCcj…"
# test
echo -n "CiQAUqQA4o9w4O3ovBCcj…" | kms-decrypt -r "projects/[PROJECT_ID]/locations/[LOCATION]/keyRings/[keyring_name]/cryptoKeys/[key_name]"
# test

License

glcoud-kms-scripts is released under the MIT License. See the enclosed LICENSE file for details.

Acknowledgements

This code is inspired upon the KMS encryption utilities for AWS by James Gregory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.