All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.justdevit.kotlin.boost.encryption.SensitiveText.kt Maven / Gradle / Ivy

The newest version!
package io.justdevit.kotlin.boost.encryption

/**
 * Represents sensitive text that can be either encrypted or raw.
 *
 * @property value The value of the sensitive text.
 */
sealed class SensitiveText(val value: String) {
    companion object {
        fun of(value: String): SensitiveText = if (value.startsWith(ENCRYPTED_DATA_PREFIX)) EncryptedText(value) else RawText(value)
    }
}

/**
 * Represents an encrypted text.
 *
 * @param value The encrypted value.
 */
class EncryptedText(value: String) : SensitiveText(if (value.startsWith(ENCRYPTED_DATA_PREFIX)) value.substring(ENCRYPTED_DATA_PREFIX.length) else value) {
    override fun toString() = ENCRYPTED_DATA_PREFIX + value
}

/**
 * Represents raw text that is not encrypted.
 *
 * @param value The value of the raw text.
 */
class RawText(value: String) : SensitiveText(value)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy