age icon indicating copy to clipboard operation
age copied to clipboard

Add EncryptReader

Open AlexanderYastrebov opened this issue 7 months ago • 3 comments

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 avatar Jul 28 '25 12:07 AlexanderYastrebov

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

gabyx avatar Sep 07 '25 10:09 gabyx

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 avatar Sep 07 '25 22:09 AlexanderYastrebov

This PR adds a handy function but what you are looking for is the implementation of https://github.com/FiloSottile/age/issues/644

AlexanderYastrebov avatar Sep 07 '25 22:09 AlexanderYastrebov