diff --git a/encrypt/encrypted.go b/encrypt/encrypted.go index 540c83a..6cfc2c5 100644 --- a/encrypt/encrypted.go +++ b/encrypt/encrypted.go @@ -9,16 +9,12 @@ import ( ) type Encrypt struct { - pubKey string - privKey string -} - -func NewEncrypt(pubKey, privKey string) *Encrypt { - return &Encrypt{pubKey: pubKey, privKey: privKey} + PubKey string `env:"ENCRYPT_PUBLIC_KEY"` + PrivKey string `env:"ENCRYPT_PRIVATE_KEY"` } func (e *Encrypt) EncryptStr(str string) ([]byte, error) { - block, _ := pem.Decode([]byte(e.pubKey)) + block, _ := pem.Decode([]byte(e.PubKey)) if block == nil { return nil, errors.New("failed to parse PEM block containing the public key") } @@ -39,7 +35,7 @@ func (e *Encrypt) EncryptStr(str string) ([]byte, error) { } func (e *Encrypt) DecryptStr(shifr []byte) (string, error) { - block, _ := pem.Decode([]byte(e.privKey)) + block, _ := pem.Decode([]byte(e.PrivKey)) if block == nil { return "", errors.New("failed to parse PEM block containing the private key") }