0

我尝试使用 aws kms 加密和解密对纯文本进行编码和解码。但它显示以下错误:

aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

aws help
aws <command> help
aws <command> \<subcommand> help

**Unknown options: --decode, >, ExampleEncryptedFile.txt, base64"**

我使用的命令:

    **aws kms encrypt --key-id 1234abcd-12ab-34cd-56ef-1234567890ab --
    plaintext mysecretpassword --output text --query 
       CiphertextBlob | base64 --decode > ExampleEncryptedFile**

If i use like the below it works:

        **aws kms encrypt --key-id 1234abcd-12ab-34cd-56ef-1234567890ab --
       plaintext fileb://ExamplePlaintextFile --output text --query 
        CiphertextBlob** 

       Decode also facing  issue like: **InvalidCiphertextException error** 

提前致谢!

4

1 回答 1

0

试试这些:

#Encrypt
#!/bin/bash
if [ -z $3 ]
 then
 echo 'Encrypt a file with AWS KMS'
 echo 'Usage: ./encrypt.sh <inputfile> <outputfile>'
 echo 'Example: ./encrypt.sh input.txt output.txt'
 exit 1
fi


aws kms encrypt --key-id alias/**SOME_KEY_ALIAS** --plaintext fileb://$1 --output text --query CiphertextBlob | base64 --decode > $2

#####

# Decrypt
#!/bin/bash
if [ -z $2 ]
 then
 echo 'Decrypt a file with AWS KMS'
 echo 'Usage: ./decrypt.sh <inputfile> <outputfile>'
 echo 'Example: ./decrypt.sh input.txt output.txt'
 exit 1
fi
aws kms decrypt --ciphertext-blob fileb://$1 --output text --query Plaintext | base64 --decode > $2
于 2018-04-17T13:14:50.320 回答