crypto
This commit is contained in:
parent
3d276c59b4
commit
d3d9e676c0
9 changed files with 126 additions and 34 deletions
24
pkg/op/crypto.go
Normal file
24
pkg/op/crypto.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package op
|
||||
|
||||
import "github.com/caos/utils/crypto"
|
||||
|
||||
type Crypto interface {
|
||||
Encrypt(string) (string, error)
|
||||
Decrypt(string) (string, error)
|
||||
}
|
||||
|
||||
type aesCrypto struct {
|
||||
key string
|
||||
}
|
||||
|
||||
func NewAESCrypto(key [32]byte) Crypto {
|
||||
return &aesCrypto{key: string(key[:32])}
|
||||
}
|
||||
|
||||
func (c *aesCrypto) Encrypt(s string) (string, error) {
|
||||
return crypto.EncryptAES(s, c.key)
|
||||
}
|
||||
|
||||
func (c *aesCrypto) Decrypt(s string) (string, error) {
|
||||
return crypto.DecryptAES(s, c.key)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue