better error management + shortcode overflow control
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package meowlib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func SymEncrypt(password string, data []byte) ([]byte, error) {
|
||||
@@ -12,7 +13,7 @@ func SymEncrypt(password string, data []byte) ([]byte, error) {
|
||||
|
||||
pgpMessage, err = crypto.EncryptMessageWithPassword(message, []byte(password))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "gopenpgp: unable to encrypt message with password")
|
||||
return nil, fmt.Errorf("gopenpgp: unable to encrypt message with password: %w", err)
|
||||
}
|
||||
return pgpMessage.GetBinary(), nil
|
||||
}
|
||||
@@ -25,7 +26,7 @@ func SymDecrypt(password string, data []byte) ([]byte, error) {
|
||||
pgpMessage = crypto.NewPGPMessage(data)
|
||||
message, err = crypto.DecryptMessageWithPassword(pgpMessage, []byte(password))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "gopenpgp: unable to decrypt message with password")
|
||||
return nil, fmt.Errorf("gopenpgp: unable to decrypt message with password: %w", err)
|
||||
}
|
||||
return message.GetBinary(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user