Groovy Documentation

nu.studer.gradle.credentials.domain
[Java] Class Encryption

java.lang.Object
  nu.studer.gradle.credentials.domain.Encryption

public final class Encryption

Encryption/decryption of text using ciphers.

Note: The author of this class is by far not a security expert. The chosen implementation has been primarily gathered from examples in the javax.crypto Javadoc and from discussions on StackOverflow.

See also here for a more detailed explanation on the selected security algorithms.


Constructor Summary
Encryption(javax.crypto.Cipher ecipher, javax.crypto.Cipher dcipher)

 
Method Summary
static Encryption createEncryption(char[] passphrase)

Creates a new Encryption instance that uses password-based encryption (PBE).

java.lang.String decrypt(java.lang.String string)

Decrypts the given text.

java.lang.String encrypt(java.lang.String string)

Encrypts the given text.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Constructor Detail

Encryption

public Encryption(javax.crypto.Cipher ecipher, javax.crypto.Cipher dcipher)


 
Method Detail

createEncryption

public static Encryption createEncryption(char[] passphrase)
Creates a new Encryption instance that uses password-based encryption (PBE). The algorithm used to create the secret key is PBEWithMD5AndDES.
throws:
RuntimeException with wrapped GeneralSecurityException in case of crypto-related exceptions
Parameters:
passphrase - the passphrase to apply when creating the secret key
Returns:
the new Encryption instance


decrypt

public java.lang.String decrypt(java.lang.String string)
Decrypts the given text.
Parameters:
string - the text to decrypt
Returns:
the decrypted text


encrypt

public java.lang.String encrypt(java.lang.String string)
Encrypts the given text.
Parameters:
string - the text to encrypt
Returns:
the encrypted text


 

Groovy Documentation