I have quite big String (~20M). It needs to be encrypted and downloaded as a file and then, eventually, uploaded back, decrypted & used. Encryption key or password belongs to the application/server (i.e. it is not specific to the user logged in).
What would be the best and simple to use package to achieve this?
Alternatively, it is also possible to use rclone. The following function decrypts a folder which was encrypted via rclone and does so without using a rclone config file. This makes it easier to use in things like CI jobs
function decrypt_data()
crypt_password = ENV["OBSCURED_ENCRYPTION_PASSWORD"]
from = joinpath(homedir(), "data")
to = joinpath(homedir(), "decrypted-data")
args = [
"--crypt-password=$crypt_password",
"--crypt-remote=/",
"--crypt-filename-encryption=off",
"--crypt-directory-name-encryption=false",
"copy",
":crypt:$from",
to
]
Rclone_jll.rclone() do bin
run(`$bin $args`)
end
end
using OpenSSL_jll
passphrase = "hunter2"
open("hello.txt", "r") do io
open("hello.txt.encrypted", "w") do io2
openssl() do prog
encrypter = `$(prog) enc -aes-256-cbc -pbkdf2 -pass pass:$(passphrase)`
run(pipeline(encrypter, stdin=io, stdout=io2))
end
end
end
open("hello.txt.encrypted", "r") do io
open("hello.txt.decrypted", "w") do io2
openssl() do prog
decrypter = `$(prog) enc -d -aes-256-cbc -pbkdf2 -pass pass:$(passphrase)`
run(pipeline(decrypter, stdin=io, stdout=io2))
end
end
end