mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-21 04:11:16 +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")
|
|
}
|