com.github.rs3vans.krypto

Package com.github.rs3vans.krypto

Types

AsymmetricCipherPair class AsymmetricCipherPair : EncryptCipher, DecryptCipher

An encrypting/decrypting cipher which wraps both an AsymmetricEncryptCipher and a AsymmetricDecryptCipher.

AsymmetricDecryptCipher class AsymmetricDecryptCipher : ConcreteCipher, DecryptCipher

An decrypting-only cipher which uses an RSA-based PrivateKey for decryption.

AsymmetricEncryptCipher class AsymmetricEncryptCipher : ConcreteCipher, EncryptCipher

An encrypting-only cipher which uses an RSA-based PublicKey for encryption.

AuthenticatingBlockCipher class AuthenticatingBlockCipher : ConcreteCipher, EncryptCipher, DecryptCipher

An encrypting/decrypting cipher which uses the Galois-counter mode (GCM).

BlockCipher class BlockCipher : ConcreteCipher, EncryptCipher, DecryptCipher

An encrypting/decrypting cipher which uses the chained-block mode (CBC).

Bytes class Bytes : Any

A class that wraps a ByteArray, providing ease-of-use and additional functionality.

ConcreteCipher abstract class ConcreteCipher : Any

A simple base class that defines a cipher which wraps an instance Cipher along with a Key.

DecryptCipher interface DecryptCipher : Any

A contract for a cipher that can decrypt an instance of Encrypted, producing an instance of Decrypted.

Decrypted data class Decrypted : Any

Represents data that is not encrypted (and may have been the result of a decryption).

DigestBuilder interface DigestBuilder : Any

A builder-style contract for digesting a message.

Digester abstract class Digester : Any

A base class which describes an object that can one-way digest a message (some data).

EncryptCipher interface EncryptCipher : Any

A contract for a cipher that can encrypt an instance of Decrypted, producing an instance of Encrypted.

Encrypted data class Encrypted : Any

Represents data that is encrypted (and may have been the result of an encryption).

HashAlgorithms object HashAlgorithms : Any

Some common algorithms used when creating a one-way hash digest.

HashDigester class HashDigester : Digester

A Digester implementation that uses a straight-forward hash.

HmacAlgorithms object HmacAlgorithms : Any

Some common algorithms used when creating an HMAC digest.

HmacDigester class HmacDigester : Digester

A Digester implementation which uses HMAC.

KryptoProvider class KryptoProvider : Any

A class that encapsulates a JCE provider.

Extensions for External Classes

java.io.InputStream
java.io.Serializable
java.nio.ByteBuffer
java.security.Key
kotlin.ByteArray
kotlin.CharSequence

Functions

deriveAesKeyFromPassword fun deriveAesKeyFromPassword(password: CharArray, salt: Bytes, iterations: Int = PBE_KEY_DEFAULT_ITERATIONS, provider: KryptoProvider = KryptoProvider.defaultInstance): SecretKey

Derives a new AES key from the given password using a strong PBE-based algorithm.

generateRandomAesKey fun generateRandomAesKey(random: SecureRandom? = null, provider: KryptoProvider = KryptoProvider.defaultInstance): SecretKey

Generates a random AES key.

generateRandomAsymmetricKeyPair fun generateRandomAsymmetricKeyPair(random: SecureRandom? = null, provider: KryptoProvider = KryptoProvider.defaultInstance): KeyPair

Generates a random KeyPair for asymmetric (RSA-based) encryption/decryption.

hashPassword fun hashPassword(password: String, salt: Bytes = generateRandomBytes()): String

Securely hash a password using the given salt (or a random one), returning a Base64 encoded String with an embedded salt.

importAesKey fun importAesKey(bytes: Bytes): SecretKey

Imports an AES key from an instance of Bytes.

importAsymmetricKeyPair fun importAsymmetricKeyPair(publicBytes: Bytes, privateBytes: Bytes, provider: KryptoProvider = KryptoProvider.defaultInstance): KeyPair

Imports RSA-basedPublicKey and private keys as a pair.

importPrivateKey fun importPrivateKey(bytes: Bytes, provider: KryptoProvider = KryptoProvider.defaultInstance): PrivateKey

Imports an RSA-based private key from an instance of Bytes.

importPublicKey fun importPublicKey(bytes: Bytes, provider: KryptoProvider = KryptoProvider.defaultInstance): PublicKey

Imports a RSA-based public key from an instance of Bytes.

matchesPasswordHash fun matchesPasswordHash(password: String, hash: String, saltSize: Int = DEFAULT_RANDOM_BYTES_SIZE): Boolean

Checks to see if the given hash value matches the (re)hashing of this string.