mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-14 02:52:42 +00:00
17 lines
523 B
Go
17 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")
|
|
}
|