Skip to content

Instantly share code, notes, and snippets.

@jeffwong
Last active August 29, 2015 14:14
Show Gist options
  • Save jeffwong/39f519cd0518428bce74 to your computer and use it in GitHub Desktop.
Save jeffwong/39f519cd0518428bce74 to your computer and use it in GitHub Desktop.
Hash and Unhash strings
hashStrings = function(x) {
sapply(x, function(i) {
sprintf("hash_%s", paste0(charToRaw(i), collapse=""))
})
}
unhashStrings = function(x) {
sapply(x, function(i) {
i = gsub("hash_", "", i)
i.split = strsplit(i, "")[[1]]
rawToChar(as.raw(as.hexmode((paste(paste0(i.split[c(TRUE, FALSE)], i.split[c(FALSE, TRUE)]), sep = ' ')))))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment