Class SymmetricKey

java.lang.Object
marauroa.common.crypto.SymmetricKey

public class SymmetricKey extends Object
Symmetric Key crypto
Author:
hendrik
  • Constructor Details

    • SymmetricKey

      public SymmetricKey(byte[] key)
      creates a new SymmetricKey
      Parameters:
      key - key (at least 128 random bits)
  • Method Details

    • encrypt

      public byte[] encrypt(byte[] initialisationVector, byte[] data) throws GeneralSecurityException
      encrypts data
      Parameters:
      initialisationVector - random data of the same length as the key
      data - data to encrypt
      Returns:
      encrypted data
      Throws:
      GeneralSecurityException - in case of a security error
    • decrypt

      public byte[] decrypt(byte[] initialisationVector, byte[] encrypted) throws GeneralSecurityException
      deencrypts data
      Parameters:
      initialisationVector - random data of the same length as the key
      encrypted - encrytped data to decrypt
      Returns:
      encrypted data
      Throws:
      GeneralSecurityException - in case of a security error