xcode: Encrypt or decrypt character string

Description Usage Arguments Details Value Examples

Description

Encrypt or decrypt character string

Usage

1
2
3
4
5
6
7
xcode(
  text,
  key = "1VerySecretPasword",
  ed = c("e", "d"),
  trans = "cfcvp",
  noe = FALSE
)

Arguments

text

Character string or raw vector to encrypt or character string to decrypt

key

Character string with encryption/decryption key. Only the letters (in upper or lower case), digits, the character # and the space are allowed in this key

ed

Character ('e' or 'd' or their upper case versions) that specifies what to do: 'e' is encrypt, 'd' is decrypt

trans

Character string with encrypt/decrypt operations. See Details

noe

Logical scalar that when set to TRUE will imit the e operation. Normally the default value of FALSE should be used. See Details

Details

Operations in trans are sequentially executed in the order given for an encrypt action and in reversed order for the decrypt action. All operations are working on character strings that contain a multiple of 16 characters. These characters must belong to the ordered set of the lower case letters, the upper case letters, digits, the space and the # character. This order is changed by the key: all (non-duplicated) characters from the key are placed before the other characters.

To ensure that all characters belong to this ordered set, an e operation is always added (prefixed) to trans unless noe = TRUE is used. When noe is set to TRUE the user must ensure that the string to be encrypted only contains the characters mentioned above and that the number of characters is a multiple of 2 when the p or s operation is used and a multiple of 16 when the a operation is used.

The following operations are defined (we describe only what happens in case of encryption because for decryption the reversed action is performed):

Value

a character string with the encrypted result when ed == 'e' or the decrypted result when ed == 'd'

Examples

1
2
3
4
5
6
7
8
## Not run: 
my_key <- 'Mysecret123'
(s <- xcode('my message!',my_key,ed='e'))
# [1] "8Ge8D3F4Mh1s6q z"
xcode(s,my_key,ed='d')
# [1] "my message!"

## End(Not run)

HanOostdijk/HOQCenc documentation built on Dec. 17, 2021, 10:28 p.m.