HexEncryption

com.phasmidsoftware.tableparser.crypto.HexEncryption
See theHexEncryption companion object
trait HexEncryption[A] extends Encryption[A]

Typeclass trait to deal with Encryption to/from Hex strings.

Type parameters

A

the cipher algorithm.

Attributes

Companion
object
Graph
Supertypes
trait Encryption[A]
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def checkHex(hex: String, key: Type[A], plaintext: String): IO[Boolean]

Method to check that the given Hex String really does decrypt to the given plaintext.

Method to check that the given Hex String really does decrypt to the given plaintext.

Value parameters

hex

a String of hexadecimals.

key

the secret key.

plaintext

the original plain text.

Attributes

Returns

true if the Hex string is correct.

def decryptHex(rawKey: String, hex: String): IO[String]

Given a raw key and a Hex string, do the decryption.

Given a raw key and a Hex string, do the decryption.

Value parameters

hex

a string of Hexadecimal digits representing a cipher.

rawKey

a raw key, i.e. a sequence of 16 characters.

Attributes

Returns

the decrypted String, wrapped in IO.

def encryptHex(rawKey: String, plaintext: CharSequence): IO[String]

Encrypt a plain text String with the given raw key (the inverse of decryptHex). The result is checked: it fails if it doesn't decrypt to the plain text.

Encrypt a plain text String with the given raw key (the inverse of decryptHex). The result is checked: it fails if it doesn't decrypt to the plain text.

Value parameters

plaintext

the plain text to be encrypted.

rawKey

a raw key, i.e. a sequence of 16 characters.

Attributes

Returns

a string of Hexadecimal digits representing the cipher, wrapped in IO.

def encryptWithRandomKey(plaintext: CharSequence): IO[(String, String, Boolean)]

Encrypt a plain text String but using a randomly generated key. The key, together with the encrypted text as hex and a check boolean, is returned.

Encrypt a plain text String but using a randomly generated key. The key, together with the encrypted text as hex and a check boolean, is returned.

Value parameters

plaintext

the plain text to be encrypted.

Attributes

Returns

a tuple of the raw key, the encrypted cipher (as hex), and a boolean, all wrapped in IO.

Inherited and Abstract methods

def buildKey(raw: String): IO[Type[A]]

Build a key from the given String.

Build a key from the given String.

Value parameters

raw

a String of the required length (typically the result of calling genRawKey).

Attributes

Returns

an IO of SecretKey[A]

Inherited from:
Encryption
def bytesToCipherText(bytes: Array[Byte]): IO[CipherText[A]]

THe inverse of concat.

THe inverse of concat.

Value parameters

bytes

the byte array.

Attributes

Returns

an IO of CipherText[A].

Inherited from:
Encryption
def concat(cipher: CipherText[A]): IO[Array[Byte]]

Show the given cipher text as a an array of bytes.

Show the given cipher text as a an array of bytes.

Value parameters

cipher

an instance of CipherText[A].

Attributes

Returns

an IO of Array[Byte].

Inherited from:
Encryption
def decrypt(key: Type[A])(cipher: CipherText[A]): IO[String]

Decrypt the given cipher text.

Decrypt the given cipher text.

Value parameters

cipher

an instance of CipherText[A].

key

the key with which to decrypt the cipher text.

Attributes

Returns

an IO of String.

Inherited from:
Encryption
def encrypt(key: Type[A])(plaintext: String): IO[CipherText[A]]

Encrypt a plain text String.

Encrypt a plain text String.

Value parameters

key

the key with which to encrypt the plain text.

plaintext

the plain text to encrypt.

Attributes

Returns

an IO of CipherText[A].

Inherited from:
Encryption
def genRawKey: IO[String]

Generate a random String of the required length.

Generate a random String of the required length.

Attributes

Returns

an IO of String.

Inherited from:
Encryption