Package org.geysermc.floodgate.crypto
Interface FloodgateCipher
- All Known Implementing Classes:
AesCipher
public interface FloodgateCipher
Responsible for both encrypting and decrypting data
-
Field Summary
Modifier and TypeFieldDescriptionstatic byte[]
static byte[]
static int
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
checkHeader(byte[] data)
Checks if the header is valid.byte[]
decrypt(byte[] data)
Decrypts the given data using the Key provided ininit(Key)
default byte[]
decryptFromString(String data)
Decrypts a String.
This method internally callsdecrypt(byte[])
by converting the UTF-8 String into a byte[]default String
decryptToString(byte[] data)
Decrypts a byte[] and turn it into a String.
This method internally callsdecrypt(byte[])
and converts the returned byte[] into a String.byte[]
encrypt(byte[] data)
Encrypts the given data using the Key provided ininit(Key)
default byte[]
encryptFromString(String data)
Encrypts data from a String.
This method internally callsencrypt(byte[])
void
Initializes the instance by giving it the key it needs to encrypt or decrypt datastatic int
-
Field Details
-
VERSION
static final int VERSION- See Also:
- Constant Field Values
-
IDENTIFIER
static final byte[] IDENTIFIER -
HEADER
static final byte[] HEADER
-
-
Method Details
-
version
-
init
Initializes the instance by giving it the key it needs to encrypt or decrypt data- Parameters:
key
- the key used to encrypt and decrypt data
-
encrypt
Encrypts the given data using the Key provided ininit(Key)
- Parameters:
data
- the data to encrypt- Returns:
- the encrypted data
- Throws:
Exception
- when the encryption failed
-
encryptFromString
Encrypts data from a String.
This method internally callsencrypt(byte[])
- Parameters:
data
- the data to encrypt- Returns:
- the encrypted data
- Throws:
Exception
- when the encryption failed
-
decrypt
Decrypts the given data using the Key provided ininit(Key)
- Parameters:
data
- the data to decrypt- Returns:
- the decrypted data
- Throws:
Exception
- when the decrypting failed
-
decryptToString
Decrypts a byte[] and turn it into a String.
This method internally callsdecrypt(byte[])
and converts the returned byte[] into a String.- Parameters:
data
- the data to encrypt- Returns:
- the decrypted data in a UTF-8 String
- Throws:
Exception
- when the decrypting failed
-
decryptFromString
Decrypts a String.
This method internally callsdecrypt(byte[])
by converting the UTF-8 String into a byte[]- Parameters:
data
- the data to decrypt- Returns:
- the decrypted data in a byte[]
- Throws:
Exception
- when the decrypting failed
-
checkHeader
Checks if the header is valid. This method will throw an InvalidFormatException when the header is invalid.- Parameters:
data
- the data to check- Throws:
InvalidFormatException
- when the header is invalid
-