[R] Encrypt/decrypt in R

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Mar 19 18:35:59 CET 2010

On Fri, Mar 19, 2010 at 5:10 PM, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
> On Fri, Mar 19, 2010 at 5:00 PM, Hadley Wickham <hadley at rice.edu> wrote:
>> Hi all,
>> Does any one know of any encryption/decryption algorithms in R?  I'm
>> not looking for anything robust - I want some way of printing output
>> to the screen that the user can't read immediately, but can decrypt a
>> little later.  The main thing I don't want to the user to see is a
>> number, so (e.g.) ROT13 isn't appropriate.
>  You could just include the numbers in a ROT13-sort of algorithm. It
> would end up being ROT-18 I guess...

 "ROT-18" (?) using chartr:

 > oldletters=c(letters,0:9)
 > old=paste(oldletters,collapse="")
 > new=paste(c(oldletters[19:36],oldletters[1:18]),collapse="")
 > chartr(old,new,message)
 [1] "g6c zsdw e65 kl.qr v633s9a"
 > chartr(old,new,chartr(old,new,message))
 [1] "you have won 23.89 dollars"


More information about the R-help mailing list