MCPcopy Create free account
hub / github.com/DNSCrypt/encrypted-dns-server / bin2hex

Function bin2hex

src/crypto.rs:297–309  ·  view source on GitHub ↗
(bin: &[u8])

Source from the content-addressed store, hash-verified

295}
296
297pub fn bin2hex(bin: &[u8]) -> String {
298 let bin_len = bin.len();
299 let hex_len = bin_len * 2 + 1;
300 let mut hex = vec![0u8; hex_len];
301 unsafe {
302 sodium_bin2hex(hex.as_mut_ptr() as *mut _, hex_len, bin.as_ptr(), bin_len);
303 }
304 CStr::from_bytes_with_nul(&hex)
305 .unwrap()
306 .to_str()
307 .unwrap()
308 .to_string()
309}
310
311pub fn init() -> Result<(), Error> {
312 let res = unsafe { sodium_init() };

Callers 1

as_stringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected