Skip to content

Instantly share code, notes, and snippets.

@trestletech
Created January 19, 2016 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trestletech/69b559016d74ff2fe430 to your computer and use it in GitHub Desktop.
Save trestletech/69b559016d74ff2fe430 to your computer and use it in GitHub Desktop.
encrypting arbitrary amounts of data in R using PKI
library(PKI)
txt <- ("This is an encryption test that has a variety of characters and is fairly long so that we can test whether or not it's actually using the stream cipher")
corpus <- paste(rep(txt, 5000), collapse="")
x <- charToRaw(corpus)
length(x)
key <- PKI.digest(charToRaw("this is a small key but it's getting bigger by the second"), "SHA256")
ae <- PKI.encrypt(x, key, "aes256")
ad <- PKI.decrypt(ae, key, "aes256")
stopifnot(identical(x, ad))
stopifnot(!identical(ad, ae))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment