Code Monkey home page Code Monkey logo

aws-kms-cmk-nodejs's Introduction

AWS CLI 환경 구성

$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$ sudo installer -pkg AWSCLIV2.pkg -target /
$ aws configure
> input resource

원본 암호화 및 삭제

// KMS 마스터 키를 이용해 keys 를 생성 합니다. 
aws kms generate-data-key --key-id (alias or keyId) --key-spec AES_256 --region origin > cli/out/keys.txt

//
echo "Plaintext-value" | base64 --decode > cli/out/datakey

// 생성된 keys 에 CiphertextBlob를 decode 합니다. (후에 decode 된 CiphertextBlob 을 이용해서 Plaintext 를 복호화 합니다.)
echo "CiphertextBlob-value" | base64 --decode > cli/out/encrypted-datakey

// decode 된 Plaintext 의 datakey로 원본 데이타를 암호화 합니다.
openssl enc -in ./cli/original.txt -out ./cli/out/original-encrypted.txt -e -aes256 -k fileb://./cli/out/datakey

// 키 복구 확인을 위해, 원본 데이타 (orifinal.txt) 와 원본 데이타의 암호화에 사용했던 dataKey는 삭제 합니다.

원본 복구


// Plaintext 의 복구를 위해서 encrypted-datakey 를  decrypt 합니다. 
aws kms decrypt --ciphertext-blob fileb://./cli/out/encrypted-datakey --region origin

// Plaintext  통해서 datakey 를 다시 복구 할 수 있습니다.
echo "Plaintext-value" | base64 --decode > cli/out/datakey

// 복구된 datakey 를 이용해서 삭제된 original 파일을 복구 할 수 있습니다. 
openssl enc -in ./cli/out/original-encrypted.txt -out ./cli/out/original-recovered.txt -d -aes256 -k fileb://./cli/out/datakey

실행

$ npx ts-node src/main.ts

aws-kms-cmk-nodejs's People

Contributors

aw-birdgang avatar

Watchers

 avatar

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.