CryptService

com.github.cloudfiles.crypt.service.CryptService
object CryptService

A module offering functionality related to cryptographic operations.

The functions provided by this service simplify the usage of a CryptStage to encrypt or decrypt data obtained from different sources.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def decodeBase64(textBase64: String): Try[ByteString]

Decodes the given Base64 string to its original byte chunk representation. Returns a ''Failure'' with a meaningful exception message if the input string contains unexpected characters.

Decodes the given Base64 string to its original byte chunk representation. Returns a ''Failure'' with a meaningful exception message if the input string contains unexpected characters.

Value parameters

textBase64

the Base64-encoded string

Attributes

Returns

a ''Try'' with the decoded data

def decryptSource[Mat](algorithm: CryptAlgorithm, key: Key, source: Source[ByteString, Mat])(implicit secRandom: SecureRandom): Source[ByteString, Mat]

Returns a source derived from the provided one, but with decryption added using the specified algorithm and key. This function basically adds a CryptStage with a proper configuration to the source.

Returns a source derived from the provided one, but with decryption added using the specified algorithm and key. This function basically adds a CryptStage with a proper configuration to the source.

Type parameters

Mat

the type of the data materialized by the source

Value parameters

algorithm

the ''CryptAlgorithm''

key

the key for decryption

secRandom

the random object

source

the source to decrypt

Attributes

Returns

the source applying the decryption transformation

def decryptText(algorithm: CryptAlgorithm, key: Key, text: ByteString)(implicit secRandom: SecureRandom): String

Decrypts the given block of data using a specific algorithm and key.

Decrypts the given block of data using a specific algorithm and key.

Value parameters

algorithm

the ''CryptAlgorithm''

key

the key for decryption

secRandom

the random object

text

the text to be decrypted as ''ByteString''

Attributes

Returns

the result of the decryption

def decryptTextFromBase64(algorithm: CryptAlgorithm, key: Key, textBase64: String)(implicit secureRandom: SecureRandom): Try[String]

Decrypts the given Base64-encoded input data using a specific algorithm and key. This operation can fail if the input string contains unexpected characters; therefore, this function returns a ''Try''. In case of a failure, the exception contains a meaningful message.

Decrypts the given Base64-encoded input data using a specific algorithm and key. This operation can fail if the input string contains unexpected characters; therefore, this function returns a ''Try''. In case of a failure, the exception contains a meaningful message.

Value parameters

algorithm

the ''CryptAlgorithm''

key

the key for decryption

secureRandom

the random object

textBase64

the Base64-encoded input string

Attributes

Returns

a ''Try'' with the resulting decrypted string

def encodeBase64(data: ByteString): String

Encodes the given data to a Base64 string using URL-safe encoding. A Base64 encoding is a good way to represent encrypted text as strings.

Encodes the given data to a Base64 string using URL-safe encoding. A Base64 encoding is a good way to represent encrypted text as strings.

Value parameters

data

the data to be encoded

Attributes

Returns

the encoded data

def encryptSource[Mat](algorithm: CryptAlgorithm, key: Key, source: Source[ByteString, Mat])(implicit secRandom: SecureRandom): Source[ByteString, Mat]

Returns a source derived from the provided one, but with encryption added using the specified algorithm and key. This function basically adds a CryptStage with a proper configuration to the source.

Returns a source derived from the provided one, but with encryption added using the specified algorithm and key. This function basically adds a CryptStage with a proper configuration to the source.

Type parameters

Mat

the type of the data materialized by the source

Value parameters

algorithm

the ''CryptAlgorithm''

key

the key for encryption

secRandom

the random object

source

the source to encrypt

Attributes

Returns

the source applying an encryption transformation

def encryptText(algorithm: CryptAlgorithm, key: Key, text: String)(implicit secRandom: SecureRandom): ByteString

Encrypts the given string using a specific algorithm and key.

Encrypts the given string using a specific algorithm and key.

Value parameters

algorithm

the ''CryptAlgorithm''

key

the key for encryption

secRandom

the random object

text

the input string

Attributes

Returns

the result of the encryption

def encryptTextToBase64(algorithm: CryptAlgorithm, key: Key, text: String)(implicit secRandom: SecureRandom): String

Encrypts the given string using a specific algorithm and key and encodes the result to Base64. This is a convenience function that combines the encrypt with the encode operation.

Encrypts the given string using a specific algorithm and key and encodes the result to Base64. This is a convenience function that combines the encrypt with the encode operation.

Value parameters

algorithm

the ''CryptAlgorithm''

key

the key for encryption

secRandom

the random object

text

the input string

Attributes

Returns

the Base64-encoded encrypted string