sm4_encrypt_ecb_to_file {smcryptoR}R Documentation

SM4 Encrypt/Decrypt - file

Description

For ease of use, we have provided functions to encrypt or decrypt data directly from files.

Usage

sm4_encrypt_ecb_to_file(input_file, output_file, key)

sm4_decrypt_ecb_from_file(input_file, output_file, key)

sm4_encrypt_cbc_to_file(input_file, output_file, key, iv)

sm4_decrypt_cbc_from_file(input_file, output_file, key, iv)

Arguments

input_file

the original file for encrypt, or the encrypted file for decrypt

output_file

the encrypted file for encrypt, or the decrypted file for decrypt

key

the key, must be a raw vector of length 16

iv

the initialization vector, must be a raw vector of 16

Value

sm4_encrypt_ecb_to_file

returns nothing, and an encrypted file will be saved in the specified path using ecb mode

sm4_decrypt_ecb_from_file

returns nothing, and a decrypted file will be saved in the specified path using ecb mode

sm4_encrypt_cbc_to_file

returns nothing, and an encrypted file will be saved in the specified path using cbc mode

sm4_decrypt_cbc_from_file

returns nothing, and a decrypted file will be saved in the specified path using cbc mode

Examples

## Not run: 
  key <- '1234567812345678' |> charToRaw()
  iv <- '0000000000000000' |> charToRaw()
  ## ecb mode
  sm4_encrypt_ecb_to_file('a.txt', 'a.enc', key)
  sm4_decrypt_ecb_from_file('a.enc', 'a.dec', key)
  ## cbc mode
  sm4_encrypt_cbc_to_file('a.txt', 'a.enc', key, iv)
  sm4_decrypt_cbc_from_file('a.enc', 'a.dec', key, iv)

## End(Not run)

[Package smcryptoR version 0.1.2 Index]