Skip to content

Conversation

AlexanderYastrebov
Copy link
Contributor

@AlexanderYastrebov AlexanderYastrebov commented Jul 28, 2025

Add EncryptReader function to encrypt io.Reader (pull-based encryption) and use it in cmd/age to get rid of io.Copy.

Updates #644

@AlexanderYastrebov AlexanderYastrebov force-pushed the encrypt-reader branch 2 times, most recently from bf2ee21 to 0962d50 Compare July 28, 2025 14:54
Add EncryptReader function to encrypt io.Reader (pull-based encryption)
and use it in command to get rid of io.Copy.

Updates FiloSottile#644

Signed-off-by: Alexander Yastrebov <[email protected]>
@gabyx
Copy link

gabyx commented Sep 7, 2025

This PR is nice and we need it, would it make sense to add this?

func EncryptStream(src io.Reader, recipients ... Recipient) (dst io.Reader, error) {
	pr, pw := io.Pipe()
	return pr, EncryptReader(pw, src, recipients...)
}

We wrap it currently as: https://gitlab.com/data-custodian/custodian/-/blob/88e7389ec5b837672f2b76fd82aaed68a4145e72/components/lib-common/pkg/crypto/reader.go

@AlexanderYastrebov
Copy link
Contributor Author

This PR is nice and we need it, would it make sense to add this?

I think this won't work as writes to pipe will block without corresponding reads.

@AlexanderYastrebov
Copy link
Contributor Author

This PR adds a handy function but what you are looking for is the implementation of #644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants