[R] Help with decrypting
Marc Schwartz
marc_schwartz at me.com
Tue Nov 8 00:30:42 CET 2016
> On Nov 7, 2016, at 4:47 PM, MacQueen, Don <macqueen1 at llnl.gov> wrote:
>
> I have a file containing encrypted contents. The contents can be decrypted
> using perl, like this:
>
> open (FILEHANDLE, "/path/to/file")
> chomp ($ciphertext = <FILEHANDLE>);
>
>
> use Crypt::CBC;
> $cipher = Crypt::CBC->new( -key => 'my secret key',
> -cipher => 'Blowfish'
> );
>
> $plaintext = $cipher->decrypt($ciphertext);
>
>
> (See http://search.cpan.org/~lds/Crypt-CBC-2.33/CBC.pm)
>
> M goal is to have the value of $plaintext in an R object, so, is there an
> R equivalent to this decrypt() perl function?
>
> I've found R packages
> bcrypt
> sodium
> that appear to have potential, but I don't understand this business well
> enough to figure out how to use them, if indeed they can be used, for
> this. Help would be much appreciated.
>
> Thanks
> -Don
>
Hi Don,
Blowfish is Bruce Schneier's algorithm from the early 90's, which even Bruce suggested some time ago not be used. Bruce has some alternative Blowfish implementations available via his web site:
https://www.schneier.com/academic/blowfish/download.html <https://www.schneier.com/academic/blowfish/download.html>
and there is a link there for some third party products that still have it and might provide for a CLI based interface as an alternative (e.g. GnuPG) if you need to use it.
>From what I can tell, 'sodium' does not support Blowfish and the implementation in bcrypt, if I am reading correctly, only provides for a one-way hash implementation, as opposed to encrypt/decrypt functions.
Thus, barring that my searching for alternative R implementations of Blowfish resulted in a Type II error, I do not see any R implementations of Blowfish that support encrypt/decrypt.
If you want to use the Perl module implementation via R, you can take a look at my WriteXLS package on GitHub:
https://github.com/marcschwartz/WriteXLS <https://github.com/marcschwartz/WriteXLS>
and see how I call Perl scripts within WriteXLS.R:
https://github.com/marcschwartz/WriteXLS/blob/master/R/WriteXLS.R <https://github.com/marcschwartz/WriteXLS/blob/master/R/WriteXLS.R>
around line 242.
That might provide one method for you.
That all being said, as per Bruce's recommendation, there are "better" encryption/decryption algorithms these days (some in the 'digest' package by Dirk), depending upon who you are trying to protect the data from... :-)
Regards,
Marc Schwartz
[[alternative HTML version deleted]]
More information about the R-help
mailing list