Package de.craftsblock.craftsnet.utils
Class SecureEncodingUtils
java.lang.Object
de.craftsblock.craftsnet.utils.SecureEncodingUtils
Utility class for secure encoding and decoding of character arrays to byte arrays and vice versa.
This class provides methods to convert between char[] and byte[] while minimizing sensitive data retention in memory by clearing intermediate buffers after use.
- Since:
- 3.4.1-SNAPSHOT
-
Method Summary
Modifier and TypeMethodDescriptionstatic char[]Decodes the given byte array into a char array using the specified charset.static byte[]Encodes a given array of chars into a byte array.
-
Method Details
-
encode
Encodes a given array of chars into a byte array.- Parameters:
chars- The input character array to encodecharset- The charset to use for encoding; must not be null- Returns:
- A byte array containing the bytes of the input characters
- Throws:
RuntimeException- If the encoding fails
-
decode
Decodes the given byte array into a char array using the specified charset.- Parameters:
bytes- The byte array containing the encoded characters; must not be nullcharset- The charset to use for decoding; must not be null- Returns:
- A char array containing the decoded characters
- Throws:
RuntimeException- If decoding fails for any reasonNullPointerException- If bytes or charset is null
-