forked from bufferapp/README
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbufcrypt
53 lines (40 loc) · 1.33 KB
/
bufcrypt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
function encrypt(){
echo $(aws kms encrypt --key-id alias/encrypter --plaintext "$1" --output text --query CiphertextBlob)
}
function decrypt(){
echo "$1" | base64 --decode > awsencrypteddata.temp
OLDIFS=$IFS
IFS=
echo $(aws kms decrypt --ciphertext-blob fileb://awsencrypteddata.temp --output text --query Plaintext | base64 --decode)
IFS=$OLDIFS
rm awsencrypteddata.temp
}
function encryptfile(){
echo $(aws kms encrypt --key-id alias/encrypter --plaintext fileb://"$1" --output text --query CiphertextBlob)
}
function help(){
printf "
A utility to encrypt sensitive information that we might need to paste
in sensitive locations.
Usage: bufcrypt COMMAND \"input\"
Commands:
encrypt Use this to encrypt text directly via terminal.
Supports multi line strings
decrypt Use this to decrypt encrypted text. Paste the encrypted
text inside quotes
encryptfile Encrypt the contents of a file using this.
Examples:
Encrypt single line text:
bufcrypt encrypt \"senstive info goes here\"
Encrypt multi line text:
bufcrypt encrypt \"my sensitive info
goes
on multiple lines\"
Decrypt
bufcrypt decrypt \"ciphertexttodecrypt\"
Encrypt a file
bufcrypt encryptfile \"~/.aws/credentials.backup\"
"
}
$1 "$2"