Refactor vault functionality to dedicated package, fix import cycles with interface pattern, fix tests
This commit is contained in:
@@ -48,6 +48,11 @@ func encryptToRecipient(data []byte, recipient age.Recipient) ([]byte, error) {
|
||||
return EncryptToRecipient(data, recipient)
|
||||
}
|
||||
|
||||
// DecryptWithIdentity decrypts data with an identity using age (public version)
|
||||
func DecryptWithIdentity(data []byte, identity age.Identity) ([]byte, error) {
|
||||
return decryptWithIdentity(data, identity)
|
||||
}
|
||||
|
||||
// decryptWithIdentity decrypts data with an identity using age
|
||||
func decryptWithIdentity(data []byte, identity age.Identity) ([]byte, error) {
|
||||
r, err := age.Decrypt(bytes.NewReader(data), identity)
|
||||
@@ -63,6 +68,11 @@ func decryptWithIdentity(data []byte, identity age.Identity) ([]byte, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// EncryptWithPassphrase encrypts data using a passphrase with age's scrypt-based encryption (public version)
|
||||
func EncryptWithPassphrase(data []byte, passphrase string) ([]byte, error) {
|
||||
return encryptWithPassphrase(data, passphrase)
|
||||
}
|
||||
|
||||
// encryptWithPassphrase encrypts data using a passphrase with age's scrypt-based encryption
|
||||
func encryptWithPassphrase(data []byte, passphrase string) ([]byte, error) {
|
||||
recipient, err := age.NewScryptRecipient(passphrase)
|
||||
|
||||
Reference in New Issue
Block a user