Learn R Programming

rapport (version 0.31)

encrypt: Encrypt a string

Description

A simple encryption function which reorders the characters in a given string based on a predefined key. As it can be seen: the used encryption is easy to crack, do not use this for sensitive data! The key is set by default on library startup. It can be changed by modifying options('.encrypt.key') to any character string with same length as options('.encrypt.chars'). E.g. intToUtf8(sample(c(33, 36:38, 48:57, 64:90, 97:122, 192:246, 248:382), nchar(getOption('.encrypt.chars')))) would return a quite complex but readable key.

Usage

encrypt(message)

Arguments

message
a string to encrypt

Value

  • string

Details

Default parameters are read from options:

  • '.encrypt.chars',
  • '.encrypt.keys'.

References

Credits goes to Barry Rowlingson and Hadley Wickham: https://stat.ethz.ch/pipermail/r-help/2010-March/232533.html

See Also

decrypt

Examples

Run this code
encrypt("Hello world!")
encrypt(paste(names(mtcars), collapse=" "))

Run the code above in your browser using DataLab