add decrypt function

This commit is contained in:
Alex Grintsvayg 2019-02-18 14:33:05 -05:00
parent c0b19e9395
commit 969a142382
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5

View file

@ -71,6 +71,11 @@ func NewBlob(data, key, iv []byte) (Blob, error) {
return ciphertext, nil return ciphertext, nil
} }
// DecryptBlob decrypts a blob
func DecryptBlob(b Blob, key, iv []byte) ([]byte, error) {
return b.Plaintext(key, iv)
}
func (b Blob) Plaintext(key, iv []byte) ([]byte, error) { func (b Blob) Plaintext(key, iv []byte) ([]byte, error) {
blockCipher, err := aes.NewCipher(key) blockCipher, err := aes.NewCipher(key)
if err != nil { if err != nil {