Interface Base
- All Known Implementing Classes:
LazySodium,LazySodiumJava
public interface Base
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]Convert a string to directly bytes.byte[]removeNulls(byte[] bs) Remove all the null bytes from the end of a byte array.<T> Tres(int res, T object) str(byte[] bs) Converts a byte array to a string using a charset.Convert a byte array to a string with a charset.booleansuccessful(int res) booleanwrongLen(byte[] bs, int shouldBeLen) booleanwrongLen(int byteLength, int shouldBeLen) booleanwrongLen(int byteLength, long shouldBeLen)
-
Method Details
-
successful
boolean successful(int res) -
res
<T> T res(int res, T object) -
str
Converts a byte array to a string using a charset. This may not be what you want to use if you're storing this string in a database for example. This function will produce null bytes and unexpected carriage returns. Please useHelpers.Lazy.sodiumBin2Hex(byte[])to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks.- Parameters:
bs- The byte array.- Returns:
- The string.
-
str
Convert a byte array to a string with a charset. This may not be what you want to use if you're storing this string in a database for example. This function will produce null bytes and unexpected carriage returns. Please useHelpers.Lazy.sodiumBin2Hex(byte[])to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks.- Parameters:
bs- Byte array.charset- The charset.- Returns:
- The byte array as a string.
-
bytes
Convert a string to directly bytes.- Parameters:
s- The String to convert to a byte array.- Returns:
- A byte array from
s.
-
wrongLen
boolean wrongLen(byte[] bs, int shouldBeLen) -
wrongLen
boolean wrongLen(int byteLength, int shouldBeLen) -
wrongLen
boolean wrongLen(int byteLength, long shouldBeLen) -
removeNulls
byte[] removeNulls(byte[] bs) Remove all the null bytes from the end of a byte array.- Parameters:
bs- A byte array.- Returns:
- The byte array with no null bytes at the end.
-