public final class Key
extends java.lang.Object
Instances of this class are immutable.
Modifier and Type | Class and Description |
---|---|
static class |
Key.Format
The supported formats for encoding a WireGuard key.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
static Key |
fromBase64(java.lang.String str)
Decodes a WireGuard public or private key from its base64 string representation.
|
static Key |
fromBytes(byte[] bytes)
Wraps a WireGuard public or private key in an immutable container.
|
static Key |
fromHex(java.lang.String str)
Decodes a WireGuard public or private key from its hexadecimal string representation.
|
byte[] |
getBytes()
Returns the key as an array of bytes.
|
int |
hashCode() |
java.lang.String |
toBase64()
Encodes the key to base64.
|
java.lang.String |
toHex()
Encodes the key to hexadecimal ASCII characters.
|
public static Key fromBase64(java.lang.String str) throws KeyFormatException
KeyFormatException
if the source string is not well-formed.str
- the base64 string representation of a WireGuard keyKeyFormatException
public static Key fromBytes(byte[] bytes) throws KeyFormatException
KeyFormatException
if the source data is not the correct length.bytes
- an array of bytes containing a WireGuard key in binary formatKeyFormatException
public static Key fromHex(java.lang.String str) throws KeyFormatException
KeyFormatException
if the source string is not well-formed.str
- the hexadecimal string representation of a WireGuard keyKeyFormatException
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public byte[] getBytes()
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toBase64()
public java.lang.String toHex()