sm4_encrypt_ecb_base64 | R Documentation |
For ease of use, we have provided functions to encrypt data into hex or base64 format and decrypt them from these formats.
sm4_encrypt_ecb_base64(input_data, key)
sm4_encrypt_ecb_hex(input_data, key)
sm4_decrypt_ecb_base64(input_data, key)
sm4_decrypt_ecb_hex(input_data, key)
sm4_encrypt_cbc_base64(input_data, key, iv)
sm4_encrypt_cbc_hex(input_data, key, iv)
sm4_decrypt_cbc_base64(input_data, key, iv)
sm4_decrypt_cbc_hex(input_data, key, iv)
input_data |
for encrypt, data is a raw vector, for decrypt, data is a hex or base64 string |
key |
the key, must be a raw vector of length 16 |
iv |
the initialization vector, must be a raw vector of 16 |
returns a base64 string of the cipher text using ecb mode
returns a hex string of the cipher text using ecb mode
returns a raw vector of the plain text
returns a raw vector of the plain text
returns a base64 string of the cipher text using cbc mode
returns a hex string of the cipher text using cbc mode
returns a raw vector of the plain text
returns a raw vector of the plain text
## SM4 Encrypt/Decrypt - hex and base64
data <- 'abc' |> charToRaw()
key <- '1234567812345678' |> charToRaw()
iv <- '0000000000000000' |> charToRaw()
## ecb mode
enc <- sm4_encrypt_ecb_base64(data, key)
enc
dec <- sm4_decrypt_ecb_base64(enc, key)
dec
enc <- sm4_encrypt_ecb_hex(data, key)
enc
dec <- sm4_decrypt_ecb_hex(enc, key)
dec
## cbc mode
enc <- sm4_encrypt_cbc_base64(data, key, iv)
enc
dec <- sm4_decrypt_cbc_base64(enc, key, iv)
dec
enc <- sm4_encrypt_cbc_hex(data, key, iv)
enc
dec <- sm4_decrypt_cbc_hex(enc, key, iv)
dec
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.