io.sureshg.extn / kotlin.String

Extensions for kotlin.String

aes128Encrypt

fun String.aes128Encrypt(key: String): ByteArray

Encrypt this string with AES-128 using the specified key. Ported from - https://goo.gl/J1H3e5

base64

val String.base64: String

Encodes the string into Base64 encoded one.

base64Decode

val String.base64Decode: String

Decodes the base64 string.

base64DecodeBytes

val String.base64DecodeBytes: ByteArray

Decodes the base64 string to byte array. It removes all extra spaces in the input string before doing the base64 decode operation.

bg256

fun String.bg256(code: Int): String

Returns background colored string with given color code.

fun String.bg256(): String

Returns background colored string with random color.

bgGrayScale

fun String.bgGrayScale(code: Int): String

Returns background grayscale formatted string.

black

val String.black: String

blink

val String.blink: String

blue

val String.blue: String

bold

val String.bold: String

8-bit color functions.

bu

val String.bu: String

Make the string bold and underline.

bui

val String.bui: String

Make the string bold, underline & italics

color

fun String.color(vararg codes: Int): String

Returns formatted string with given ANSI color codes.

fun String.color(color: AnsiColor): String

Returns formatted string with given ANSI color.

color256

fun String.color256(code: Int, fg: Boolean = true): String

Returns 256-color extended color set (From 0 to 255) formatted string.

cyan

val String.cyan: String

decodePEM

fun String.decodePEM(): ByteArray

Decodes a PEM-encoded block to DER. PEM (Privacy-enhanced Electronic Mail) is Base64 encoded DER certificate, enclosed between "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----". The string, according to RFC 1421, can only contain characters in the base-64 alphabet and whitespaces. ToDo - Replace with PemReader.

done

val String.done: String

Completed (Beer Glass) string.

err

val String.err: String

Error string

esc

val String.esc: AnsiEsc

Returns an ANSI escape unicode of the string.

fg256

fun String.fg256(code: Int): String

Returns foreground colored string with given color code.

fun String.fg256(): String

Returns foreground colored string with random color.

fgGrayScale

fun String.fgGrayScale(code: Int): String

Returns foreground grayscale formatted string.

gray

val String.gray: String

grayScale

fun String.grayScale(code: Int, fg: Boolean = true): String

Returns 8-bit gray scale (From 232 to 256 in color set) formatted string.

green

val String.green: String

hex

val String.hex: String

Convert string to hex.

highvolt

val String.highvolt: String

High voltage string

hmacSHA1

fun String.hmacSHA1(key: String): ByteArray

Encrypt this string with HMAC-SHA1 using the specified key.

indent

fun String.indent(col: Int): String

Prepend an empty string of size col to the string.

isIPv4

val String.isIPv4: Boolean

italic

val String.italic: String

magenta

val String.magenta: String

md5

val String.md5: String

Create an MD5 hash of a string.

normalizeString

fun String.normalizeString(desiredLength: Int): String

Normalize a string to a desired length by repeatedly appending itself and/or truncating.

oct

val String.oct: String

Convert String to octal

red

val String.red: String

reversed

val String.reversed: String

rightPadString

fun String.rightPadString(padding: Char, multipleOf: Int): String

Pad this String to a desired multiple on the right using a specified character.

sha1

val String.sha1: String

Create an SHA1 hash of a string.

sha256

val String.sha256: String

Create an SHA256 hash of a string.

strike

val String.strike: String

sux

val String.sux: String

Success string

underline

val String.underline: String

warn

val String.warn: String

Warn string

yellow

val String.yellow: String