From c6d2859dd229d6ad058440feac910b9905a761d7 Mon Sep 17 00:00:00 2001 From: cyfraeviolae Date: Sun, 28 Aug 2022 02:32:00 -0400 Subject: k1 for ffff, diagrams int ext --- static/decrypt-aes-gcm.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++ static/styles.css | 13 +++++++++--- 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 static/decrypt-aes-gcm.go (limited to 'static') diff --git a/static/decrypt-aes-gcm.go b/static/decrypt-aes-gcm.go new file mode 100644 index 0000000..bab07b5 --- /dev/null +++ b/static/decrypt-aes-gcm.go @@ -0,0 +1,52 @@ +package main + +import ( + "crypto/aes" + "crypto/cipher" + "encoding/hex" + "errors" + "io/ioutil" + "os" +) + +func main() { + err := inner() + if err != nil { + panic(err.Error()) + } +} + +func inner() error { + if len(os.Args) < 3 { + return errors.New("usage: ./decrypt-aes-gcm < input-file > output-file") + } + key, err := hex.DecodeString(os.Args[1]) + if err != nil { + return err + } + nonce, err := hex.DecodeString(os.Args[2]) + if err != nil { + return err + } + ciphertext, err := ioutil.ReadAll(os.Stdin) + if err != nil { + return err + } + block, err := aes.NewCipher(key) + if err != nil { + return err + } + aesgcm, err := cipher.NewGCM(block) + if err != nil { + return err + } + plaintext, err := aesgcm.Open(nil, nonce, ciphertext, nil) + if err != nil { + return err + } + _, err = os.Stdout.Write(plaintext) + if err != nil { + return err + } + return nil +} diff --git a/static/styles.css b/static/styles.css index 5ea8a95..768aba7 100644 --- a/static/styles.css +++ b/static/styles.css @@ -20,7 +20,7 @@ ul { } pre { - white-space: pre-wrap; + /* white-space: pre-wrap; */ } details[open=""] { @@ -51,6 +51,13 @@ code { max-height: 200px; max-width: 300px; min-height: 150px; - /* width: 48%; */ - /* height: auto; */ +} + +.demo { + border: 1px dotted grey; + display: inline-block; + padding: 20px; + overflow-x: scroll; + width: 100%; + box-sizing: border-box; } -- cgit v1.2.3