mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-15 03:22:43 +00:00
18 lines
523 B
Go
18 lines
523 B
Go
|
package database
|
||
|
|
||
|
import (
|
||
|
"github.com/pkg/errors"
|
||
|
|
||
|
"github.com/Luzifer/go-openssl/v4"
|
||
|
)
|
||
|
|
||
|
func (c connector) DecryptField(dec string) (string, error) {
|
||
|
dv, err := openssl.New().DecryptBytes(c.encryptionSecret, []byte(dec), openssl.PBKDF2SHA512)
|
||
|
return string(dv), errors.Wrap(err, "decrypting value")
|
||
|
}
|
||
|
|
||
|
func (c connector) EncryptField(enc string) (string, error) {
|
||
|
ev, err := openssl.New().EncryptBytes(c.encryptionSecret, []byte(enc), openssl.PBKDF2SHA512)
|
||
|
return string(ev), errors.Wrap(err, "encrypting value")
|
||
|
}
|