# Encryptor

class Encryptor(val encryptFn: (String) -> String, val decryptFn: (String) -> String, val maxColLengthFn: (Int) -> Int)

Base cipher class responsible for the encryption and decryption of data.

#### Samples

    return AesBytesEncryptor(
        password.toString(),
        salt,
        KeyGenerators.secureRandom(AES_256_GCM_BLOCK_LENGTH),
        AesBytesEncryptor.CipherAlgorithm.GCM
    ).run {
        Encryptor(
            { base64Encoder.encodeToString(encrypt(it.toByteArray())) },
            { String(decrypt(base64Decoder.decode(it))) },
            { inputLen ->
                base64EncodedLength(AES_256_GCM_BLOCK_LENGTH + inputLen + AES_256_GCM_TAG_LENGTH)
            }
        )
    }

Content copied to clipboard

## Constructors

Encryptor
Link copied to clipboard
constructor(encryptFn: (String) -> String, decryptFn: (String) -> String, maxColLengthFn: (Int) -> Int)

## Properties

decryptFn
Link copied to clipboard
val decryptFn: (String) -> String

Decrypt ciphertext to a plaintext string.

encryptFn
Link copied to clipboard
val encryptFn: (String) -> String

Encrypt a plaintext string to ciphertext.

maxColLengthFn
Link copied to clipboard
val maxColLengthFn: (Int) -> Int

Convert the expected input length into the maximum encoded length to be stored.

## Functions

decrypt
Link copied to clipboard
fun decrypt(str: String): String

Returns a decrypted value using decryptFn.

encrypt
Link copied to clipboard
fun encrypt(str: String): String

Returns an encrypted value using encryptFn.

maxColLength
Link copied to clipboard
fun maxColLength(inputByteSize: Int): Int

Returns the maximum column length needed to store an encrypted value, using the specified inputByteSize, and determined by maxColLengthFn.