Class crypto_skcipher

Lua interface to symmetric-key ciphers (SKCIPHER).

Methods

crypto_skcipher:blocksize () Returns the cipher block size in bytes.
crypto_skcipher:decrypt (iv, data) Decrypts data.
crypto_skcipher:encrypt (iv, data) Encrypts data.
crypto_skcipher:ivsize () Returns the required IV size in bytes.
crypto_skcipher:new (algname) Creates a new SKCIPHER transform object.
crypto_skcipher:setkey (key) Sets the cipher key.


Methods

crypto_skcipher:blocksize ()
Returns the cipher block size in bytes.

Returns:

    integer
crypto_skcipher:decrypt (iv, data)
Decrypts data. IV length must match ivsize().

Parameters:

Returns:

    string plaintext (same length as input)

Raises:

on decryption failure or incorrect IV length
crypto_skcipher:encrypt (iv, data)
Encrypts data. IV length must match ivsize().

Parameters:

Returns:

    string ciphertext (same length as input)

Raises:

on encryption failure or incorrect IV length
crypto_skcipher:ivsize ()
Returns the required IV size in bytes.

Returns:

    integer
crypto_skcipher:new (algname)
Creates a new SKCIPHER transform object.

Parameters:

  • algname string algorithm name (e.g., "cbc(aes)", "ctr(aes)")

Returns:

    crypto_skcipher

Raises:

on allocation failure

Usage:

    local skcipher = require("crypto").skcipher
    local cipher = skcipher("cbc(aes)")
crypto_skcipher:setkey (key)
Sets the cipher key.

Parameters:

Raises:

on invalid key length or algorithm error
generated by LDoc 1.5.0 Last updated 2026-03-31 12:21:45