github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/atc/scripts/db_decrypt.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/pf-qiu/concourse/v6/atc/db/encryption" 7 "github.com/concourse/flag" 8 flags "github.com/jessevdk/go-flags" 9 ) 10 11 type ConcryptCommand struct { 12 Key flag.Cipher `long:"encryption-key" description:"A 16 or 32 length key used to encrypt sensitive information before storing it in the database."` 13 Ciphertext string `long:"ciphertext" description:"the ciphertext to decrypt."` 14 Nonce string `long:"nonce" description:"Nonce for decryption."` 15 } 16 17 func main() { 18 var command ConcryptCommand 19 _, err := flags.Parse(&command) 20 if err != nil { 21 panic(err) 22 } 23 plaintext, err := encryption.NewKey(command.Key.AEAD).Decrypt(command.Ciphertext, &command.Nonce) 24 if err != nil { 25 panic(err) 26 } 27 fmt.Printf("%s", plaintext) 28 }