sm2_encrypt_to_file {smcryptoR} | R Documentation |
SM2 Encrypt/Decrypt - file
Description
For ease of use, we have provided functions to encrypt or decrypt data directly from files.
Usage
sm2_encrypt_to_file(data, enc_file, public_key)
sm2_decrypt_from_file(dec_file, private_key)
Arguments
data |
data to be encrypted, must be a raw vector |
enc_file |
the enctypted file to be saved |
public_key |
a public key represented as a hexadecimal string |
dec_file |
the encrypted file to be loaded |
private_key |
a private key represented as a hexadecimal string |
Value
- sm2_encrypt_to_file
returns nothing, an encrypted file will be saved in the specified path
- sm2_decrypt_from_file
returns nothing, a decrypted file will be saved in the specified path
Examples
## encrypt and decrypt from file
## Not run:
data <- 'abc' |> charToRaw()
keypair <- sm2_gen_keypair()
private_key <- keypair$private_key
public_key <- keypair$public_key
sm2_encrypt_to_file(data, 'data.enc', public_key)
sm2_decrypt_from_file('data.enc', private_key)
## End(Not run)
[Package smcryptoR version 0.1.2 Index]