Page cover

πŸ”§Utility Class

Dozens of handy functions.

K Class Overview

  • Static Methods All methods are static, eliminating the need for object instantiation.

  • Encoding and Decoding Supports encoding and decoding for multiple formats, including URL, Base64, CSV, JSON, XML, and YAML.

  • AES-256 Encryption/Decryption Provides robust encryption and decryption using the AES/CBC/PKCS5Padding algorithm. The provided secure key is hashed with SHA-256 to create a 256-bit key. Use K.getRandomBytes(16) to generate the required initialization vector.

  • Data Compression Enables ZLIB and GZIP compression and decompression for efficient data handling.

  • Hash Generation Supports generating cryptographic hashes using MD5, SHA-2, or SHA-3 algorithms.

  • DNS Querying Allows querying of any DNS record type (e.g., MX, A). MX records are returned in priority order for convenience.

  • Thread Management Includes functionality to introduce delays in thread execution.

  • Environment Information Retrieves detailed environment data, such as JVM version, IP address, hostname, and more.

Example Delay Thread

// Wait 1/4 second
K.waitMilliseconds(250);

// Wait 5 minutes
K.waitMinutes(5);

Example Encode/Decode

Example Query DNS Server

Example AES-256

Last updated