-
public class Key
-
-
Method Summary
Modifier and Type Method Description Array<byte>getAsBytes()StringgetAsHexString()StringgetAsPlainString(Charset charset)StringgetAsPlainString()static KeyfromHexString(String hexString)Create a Key from a hexadecimal string. static KeyfromBase64String(String base64String, Base64Facade base64Facade)Create a Key from a base64 string. static KeyfromBase64String(String base64String)Create a Key from a base64 string. static KeyfromPlainString(String str)Create a Key from a regular, unmodified, not encoded string. static KeyfromPlainString(String str, Charset charset)Create a Key from a regular, unmodified, not encoded string. static KeyfromBytes(Array<byte> bytes)Create a Key by supplying raw bytes. static Keygenerate(LazySodium ls, int size)Generate a random Key with a given size. booleanequals(Object obj)-
-
Method Detail
-
getAsBytes
Array<byte> getAsBytes()
-
getAsHexString
String getAsHexString()
-
getAsPlainString
String getAsPlainString(Charset charset)
-
getAsPlainString
String getAsPlainString()
-
fromHexString
static Key fromHexString(String hexString)
Create a Key from a hexadecimal string.
- Parameters:
hexString- A hexadecimal encoded string.
-
fromBase64String
static Key fromBase64String(String base64String, Base64Facade base64Facade)
Create a Key from a base64 string.
- Parameters:
base64String- A base64 encoded string.base64Facade- A base64 encoder for Java or Android.
-
fromBase64String
static Key fromBase64String(String base64String)
Create a Key from a base64 string. Only use thisif you have initialised Sodium.base64Facade either directlyor via calling LazySodiumJava() or LazySodiumAndroid().
- Parameters:
base64String- A base64 encoded string.
-
fromPlainString
static Key fromPlainString(String str)
Create a Key from a regular, unmodified, not encoded string.
- Parameters:
str- A plain string.
-
fromPlainString
static Key fromPlainString(String str, Charset charset)
Create a Key from a regular, unmodified, not encoded string.
- Parameters:
str- A plain string.charset- The charset to use.
-
fromBytes
static Key fromBytes(Array<byte> bytes)
Create a Key by supplying raw bytes. The bytearray should not be encoded and should be from a plain string,UNLESS you know what you are doing and actively wantto provide a byte array that has been encoded.
- Parameters:
bytes- A byte array.
-
generate
static Key generate(LazySodium ls, int size)
Generate a random Key with a given size.
- Parameters:
ls- LazySodium instance as we need to get truerandom bytes.size- The size of the key to generate.
-
-
-
-