/IKI

Encryption utility that combines custom block cipher encryption with PBKDF2-based

Primary LanguageJava

IKI Encryption Library

The IKI library provides utility methods for securely encrypting and decrypting data using a custom block cipher combined with PBKDF2-based key derivation. This library is designed to offer a high level of security for text data, making use of industry-standard cryptographic techniques.

Features

  • Custom Block Cipher: Implements a simple but effective block cipher for data encryption and decryption.
  • PBKDF2 Key Derivation: Uses PBKDF2 with HMAC-SHA256 to derive encryption keys from passwords, adding a layer of security through salt and multiple iterations.
  • Concurrency: Leverages Java's ExecutorService to parallelize encryption and decryption processes, making it efficient on multi-core systems.
  • Base64 Encoding: Encrypted data is encoded in Base64 for easy storage and transmission.

Installation

To use the IKI library in your project, simply include the IKI.java class in your source code.

Usage

Encrypting Data

To encrypt a plaintext string:

import cz.venteria.IKI;

public class Example {

    public static void main(String[] args) {
        String originalText = "Super Message, you want to be secure";
        String password = ">3nvU247#Ap>B;CPi&zD$:xnJeL:DYJt";

        try {
            // Generate salt and derive the cryptographic key
            byte[] salt = IKI.generateRandomSalt();
            byte[] key = IKI.deriveKeyFromPassword(password.toCharArray(), salt);

            // Encrypt the plaintext
            String encryptedText = IKI.encrypt(originalText, key, salt);
            System.out.println("Encrypted Text: " + encryptedText);

            // Decrypt the encrypted text
            String decryptedText = IKI.decrypt(encryptedText, key, salt);
            System.out.println("Decrypted Text: " + decryptedText);
        } catch (InterruptedException e) {
            System.err.println("Encryption/Decryption process was interrupted: " + e.getMessage());
        }

    }
}

Key Derivation

To derive a key from a password:

char[] password = "superSecretPassword123".toCharArray();
byte[] salt = IKI.generateRandomSalt();
byte[] key = IKI.deriveKeyFromPassword(password, salt);

Generating Random Salt

To generate a random salt for key derivation:

byte[] salt = IKI.generateRandomSalt();

This project is licensed under the MIT License.