Step 1: mkfifo /tmp/fifo - This creates a FIFO, the name of the file representing the channel. Everything that is written into the pipe remains there until the process returns it from the pipe. Data never gets to disk.
Step 2: Run this in one terminal: openssl enc -aes-256-cbc -a -e -in fifo -out safe - runs the OpenSSL program for encryption using AES, 256-bit key, CBC mode (openssl supports many more types and encryption options, selects the one that works for you, this is a safe default value); -a Base64 encodes the output (which is good for testing, but you can probably disable it when you really use it, Base64 causes a 4/3 increase in size); -e works in encryption mode, -in fifo indicates that the input file has the name fifo (it may use the full path); -out safe indicates that the output file is named safe (again, maybe use the full path). OpenSSL will sleep until the data arrives in the channel.
OpenSSL will offer you a passphrase when some data arrives on the channel.
Check this out: run "echo foo> / tmp / fifo" in another terminal. See Password hint in the first terminal, specify the password and confirm the password, then view the contents of the file "safely":
$ openssl enc -aes-256-cbc -a -e -in fifo -out safe # (in another terminal, "echo foo > fifo") enter aes-256-cbc encryption password: Verifying - enter aes-256-cbc encryption password: $ cat safe U2FsdGVkX18aWBw0Uz8N3SfrRg4PigL609F+HQPuc6o=
Check out the other direction:
$ openssl enc -aes-256-cbc -a -d -in safe enter aes-256-cbc decryption password: foo
Now run the OpenSSL command from step 2: openssl enc -aes-256-cbc -a -e -in fifo -out safe , start your Matlab and give /tmp/fifo the SAVE() command.
It is likely that Matlab will do something stupid, like deleting any existing file with the given file name, in which case you will find your unencrypted data in a regular file with the name /tmp/fifo . Therefore, check some non-essential data first. But I hope that Matlab is written using Unix tools and simply writes to the named channel that you give it.
sarnold
source share