/// Save DHT keys to a binary file.
Save DHT keys to a binary file.
Save DHT keys to a binary file .
fn save_keys(keys_file: &str, pk: PublicKey, sk: &SecretKey) {
    #[cfg(not(unix))]
    let mut file = File::create(keys_file).expect("Failed to create the keys file");
    #[cfg(unix)]
    let mut file = OpenOptions::new()
        .create(true)
        .write(true)
        .mode(0o600)
        .open(keys_file)
        .expect("Failed to create the keys file");
    file.write_all(pk.as_ref()).expect("Failed to save public key to the keys file");
    file.write_all(&sk[0..SECRETKEYBYTES]).expect("Failed to save secret key to the keys file");
}
fn save_keys ( keys_file : & str , pk : PublicKey , sk : & SecretKey ) { # [ cfg ( not ( unix ) ) ] let mut file = File :: create ( keys_file ) . expect ( " " ) ; # [ cfg ( unix ) ] let mut file = OpenOptions :: new ( ) . create ( true ) . write ( true ) . mode ( 0o600 ) . open ( keys_file ) . expect ( " " ) ; file . write_all ( pk . as_ref ( ) ) . expect ( " " ) ; file . write_all ( & sk [ 0 .. SECRETKEYBYTES ] ) . expect ( " " ) ; }
Save DHT keys to a binary file.
Save DHT keys to a binary file .
keys_file
&str
pk
PublicKey
sk
&SecretKey