Struct wgctrl_rs::Key [−][src]
pub struct Key(pub wg_key);
Represents a WireGuard encryption key.
WireGuard makes no meaningful distinction between public, private and preshared keys - any sequence of 32 bytes can be used as either of those.
This means that you need to be careful when working with
Key
s, especially ones created from external data.
Methods
impl Key
[src]
impl Key
pub fn from_raw(key: wg_key) -> Self
[src]
pub fn from_raw(key: wg_key) -> Self
Creates a new Key
from raw bytes.
pub fn generate_private() -> Self
[src]
pub fn generate_private() -> Self
Generates and returns a new private key.
Generates and returns a new preshared key.
pub fn generate_public(&self) -> Self
[src]
pub fn generate_public(&self) -> Self
Generates a public key for this private key.
pub fn zero() -> Self
[src]
pub fn zero() -> Self
Generates an all-zero key.
pub fn is_zero(&self) -> bool
[src]
pub fn is_zero(&self) -> bool
Checks if this key is all-zero.
pub fn to_base64(&self) -> String
[src]
pub fn to_base64(&self) -> String
Converts the key to a standardized base64 representation, as used by the wg
utility and wg-quick
.
pub fn from_base64(key: &str) -> Result<Self, InvalidKey>
[src]
pub fn from_base64(key: &str) -> Result<Self, InvalidKey>
Converts a base64 representation of the key to the raw bytes.
This can fail, as not all text input is valid base64 - in this case
Err(InvalidKey)
is returned.
Trait Implementations
impl PartialEq for Key
[src]
impl PartialEq for Key
fn eq(&self, other: &Key) -> bool
[src]
fn eq(&self, other: &Key) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Key) -> bool
[src]
fn ne(&self, other: &Key) -> bool
This method tests for !=
.
impl Eq for Key
[src]
impl Eq for Key
impl Clone for Key
[src]
impl Clone for Key
fn clone(&self) -> Key
[src]
fn clone(&self) -> Key
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Key
[src]
impl Debug for Key