diff options
| -rw-r--r-- | docs-src/content/functions/crypto.yml | 3 | ||||
| -rw-r--r-- | docs/content/functions/crypto.md | 15 | ||||
| -rw-r--r-- | funcs/crypto.go | 15 |
3 files changed, 30 insertions, 3 deletions
diff --git a/docs-src/content/functions/crypto.yml b/docs-src/content/functions/crypto.yml index 741a5808..2565bd6c 100644 --- a/docs-src/content/functions/crypto.yml +++ b/docs-src/content/functions/crypto.yml @@ -28,6 +28,7 @@ funcs: $ gomplate -i '{{ crypto.Bcrypt 4 "foo" }} $2a$04$zjba3N38sjyYsw0Y7IRCme1H4gD0MJxH8Ixai0/sgsrf7s1MFUK1C - name: crypto.DecryptAES + experimental: true description: | Decrypts the given input using the given key. By default, uses AES-256-CBC, but supports 128- and 192-bit keys as well. @@ -55,6 +56,7 @@ funcs: $ gomplate -i '{{ base64.Decode "Gp2WG/fKOUsVlhcpr3oqgR+fRUNBcO1eZJ9CW+gDI18=" | crypto.DecryptAES "swordfish" 128 }}' hello world - name: crypto.DecryptAESBytes + experimental: true description: | Decrypts the given input using the given key. By default, uses AES-256-CBC, but supports 128- and 192-bit keys as well. @@ -81,6 +83,7 @@ funcs: $ gomplate -i '{{ base64.Decode "Gp2WG/fKOUsVlhcpr3oqgR+fRUNBcO1eZJ9CW+gDI18=" | crypto.DecryptAES "swordfish" 128 }}' hello world - name: crypto.EncryptAES + experimental: true description: | Encrypts the given input using the given key. By default, uses AES-256-CBC, but supports 128- and 192-bit keys as well. diff --git a/docs/content/functions/crypto.md b/docs/content/functions/crypto.md index 8834a9f0..ea204fbf 100644 --- a/docs/content/functions/crypto.md +++ b/docs/content/functions/crypto.md @@ -45,7 +45,10 @@ $ gomplate -i '{{ crypto.Bcrypt 4 "foo" }} $2a$04$zjba3N38sjyYsw0Y7IRCme1H4gD0MJxH8Ixai0/sgsrf7s1MFUK1C ``` -## `crypto.DecryptAES` +## `crypto.DecryptAES` _(experimental)_ +**Experimental:** This function is [_experimental_][experimental] and may be enabled with the [`--experimental`][experimental] flag. + +[experimental]: ../config/#experimental Decrypts the given input using the given key. By default, uses AES-256-CBC, but supports 128- and 192-bit keys as well. @@ -82,7 +85,10 @@ $ gomplate -i '{{ base64.Decode "Gp2WG/fKOUsVlhcpr3oqgR+fRUNBcO1eZJ9CW+gDI18=" | hello world ``` -## `crypto.DecryptAESBytes` +## `crypto.DecryptAESBytes` _(experimental)_ +**Experimental:** This function is [_experimental_][experimental] and may be enabled with the [`--experimental`][experimental] flag. + +[experimental]: ../config/#experimental Decrypts the given input using the given key. By default, uses AES-256-CBC, but supports 128- and 192-bit keys as well. @@ -118,7 +124,10 @@ $ gomplate -i '{{ base64.Decode "Gp2WG/fKOUsVlhcpr3oqgR+fRUNBcO1eZJ9CW+gDI18=" | hello world ``` -## `crypto.EncryptAES` +## `crypto.EncryptAES` _(experimental)_ +**Experimental:** This function is [_experimental_][experimental] and may be enabled with the [`--experimental`][experimental] flag. + +[experimental]: ../config/#experimental Encrypts the given input using the given key. By default, uses AES-256-CBC, but supports 128- and 192-bit keys as well. diff --git a/funcs/crypto.go b/funcs/crypto.go index ce671849..dc5b0508 100644 --- a/funcs/crypto.go +++ b/funcs/crypto.go @@ -289,7 +289,12 @@ func (f *CryptoFuncs) ECDSADerivePublicKey(privateKey string) (string, error) { } // EncryptAES - +// Experimental! func (f *CryptoFuncs) EncryptAES(key string, args ...interface{}) ([]byte, error) { + if err := checkExperimental(f.ctx); err != nil { + return nil, err + } + k, msg, err := parseAESArgs(key, args...) if err != nil { return nil, err @@ -299,13 +304,23 @@ func (f *CryptoFuncs) EncryptAES(key string, args ...interface{}) ([]byte, error } // DecryptAES - +// Experimental! func (f *CryptoFuncs) DecryptAES(key string, args ...interface{}) (string, error) { + if err := checkExperimental(f.ctx); err != nil { + return "", err + } + out, err := f.DecryptAESBytes(key, args...) return conv.ToString(out), err } // DecryptAESBytes - +// Experimental! func (f *CryptoFuncs) DecryptAESBytes(key string, args ...interface{}) ([]byte, error) { + if err := checkExperimental(f.ctx); err != nil { + return nil, err + } + k, msg, err := parseAESArgs(key, args...) if err != nil { return nil, err |
