Skip to content

Feature Request (library): Encrypt for io.Reader #644

@FiloSottile

Description

@FiloSottile

Discussed in #638

Originally posted by dsemi June 20, 2025
The age library API is currently implemented to allow for decrypting a Reader, or encrypting a Writer. I have a use case where it would be more convenient to be able to encrypt a Reader to allow for logic to happen in between an encrypted stream and its destination. I guess another way to phrase this would be that decrypting is pull-based, and encrypting is push-based, but I'd like to be able to use pull-based encrypting.

Note that you can sort of work around the issue by using Go's io.Pipe, but that requires an extra goroutine and the error-handling along with it that I'd like to avoid if possible.

I'd be happy to contribute a PR for this if there's no technical limitation as to why this wouldn't work. I took a quick look at internal/stream/stream.go and didn't see any obvious issue, but I might be missing something.
I don't personally have a need for it, but for symmetry I think a decrypting writer could be added as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions