symmetric-encryption icon indicating copy to clipboard operation
symmetric-encryption copied to clipboard

[Q] Encrypting file at disk and passing it to http client

Open kakoni opened this issue 7 years ago • 1 comments

Please delete this issue if this is not the proper place to ask. Anyway; I've got temporary files on disk which I need to encrypt and pass on to http client (that reads IO/streams).

Not sure how to do this right, Pass file and StringIO (as a target) to SymmetricEncryption::Writer.encrypt and then construct new StringIO object from the result?

kakoni avatar Dec 15 '17 08:12 kakoni

To read an encrypted file as a stream into another method, such as a controller download method, or http client:

    SymmetricEncryption::Reader.open('temp_file.enc') do |io|
     # Pass the decrypted stream into another library or method
      other_library(io)
    end

Note: Not all io methods are implemented. The above works for Rails controller download actions/streams.

reidmorrison avatar Jan 25 '18 00:01 reidmorrison