π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
NativeGo: Add method for encryptChacha
Neeraj Guptaf7bae0483169
diff --git a/internal/crypto/crypto_libsodium.go b/internal/crypto/crypto_libsodium.goindex 04b87844c8..9cc8c1f762 100644--- a/internal/crypto/crypto_libsodium.go+++ b/internal/crypto/crypto_libsodium.go@@ -20,7 +20,7 @@ import (// - A byte slice representing the encrypted data.// - A byte slice representing the header of the encrypted data.// - An error object, which is nil if no error occurs.-func EncryptChaCha20poly1305(data []byte, key []byte) ([]byte, []byte, error) {+func EncryptChaCha20poly1305LibSodium(data []byte, key []byte) ([]byte, []byte, error) {var buf bytes.Bufferencoder := sodium.MakeSecretStreamXCPEncoder(sodium.SecretStreamXCPKey{Bytes: key}, &buf)_, err := encoder.WriteAndClose(data)@@ -31,6 +31,18 @@ func EncryptChaCha20poly1305(data []byte, key []byte) ([]byte, []byte, error) {return buf.Bytes(), encoder.Header().Bytes, nil}+func EncryptChaCha20poly1305(data []byte, key []byte) ([]byte, []byte, error) {+ encryptor, header, err := NewEncryptor(key)+ if err != nil {+ return nil, nil, err+ }+ encoded, err := encryptor.Push(data, TagFinal)+ if err != nil {+ return nil, nil, err+ }+ return encoded, header, nil+}+// decryptChaCha20poly1305 decrypts the given data using the ChaCha20-Poly1305 algorithm.// Parameters:// - data: The encrypted data as a byte slice.