Class StringEncrypter

java.lang.Object
org.gcube.common.encryption.encrypter.StringEncrypter
All Implemented Interfaces:
Encrypter<String>

public class StringEncrypter extends Object implements Encrypter<String>
Author:
Luca Frosini (ISTI - CNR)
  • Method Details

    • getEncrypter

      public static StringEncrypter getEncrypter()
      Gets the Encrypter for String
      Returns:
      the encrypter
    • encrypt

      public String encrypt(String string) throws Exception
      Encrypts the string with the context Key
      Specified by:
      encrypt in interface Encrypter<String>
      Parameters:
      string - the string to encrypt
      Returns:
      the encrypted string in a Base64 encoding
      Throws:
      Exception - if encryption fails
    • encrypt

      public String encrypt(String string, Key ekey) throws Exception
      Encrypts the string with the given key
      Specified by:
      encrypt in interface Encrypter<String>
      Parameters:
      string - the string to encrypt
      ekey - the key for encrypting
      Returns:
      the encrypted string in a Base64 encoding
      Throws:
      Exception - if encryption fails
    • decrypt

      public String decrypt(String string) throws Exception
      Decrypts the string with the context key
      Specified by:
      decrypt in interface Encrypter<String>
      Parameters:
      string - the encrypted string to decrypt
      Returns:
      the decrypted string
      Throws:
      Exception - if decryption fails
    • decrypt

      public String decrypt(String string, Key dkey) throws Exception
      Decrypts the string with the given key
      Specified by:
      decrypt in interface Encrypter<String>
      Parameters:
      string - the encrypted string to decrypt
      dkey - the key to use for decrypting
      Returns:
      the decrypted string
      Throws:
      Exception - if decryption fails