use blake3 to hash the passphrase
This commit is contained in:
@@ -13,6 +13,7 @@ extern char * litelib_initialize_new_from_phrase
|
||||
extern char * litelib_initialize_existing (bool dangerous, const char* server);
|
||||
extern char * litelib_execute (const char* s, const char* args);
|
||||
extern void litelib_rust_free_string (char* s);
|
||||
extern char * blake3_PW (char* pw);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -29,6 +29,30 @@ pub extern fn litelib_wallet_exists(chain_name: *const c_char) -> bool {
|
||||
|
||||
println!("Wallet exists: {}", config.wallet_exists());
|
||||
config.wallet_exists()
|
||||
}
|
||||
|
||||
//////hash blake3
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn blake3_PW(pw: *const c_char) -> *mut c_char{
|
||||
|
||||
let passwd = unsafe {
|
||||
assert!(!pw.is_null());
|
||||
|
||||
CStr::from_ptr(pw).to_string_lossy().into_owned()
|
||||
};
|
||||
|
||||
let data = passwd.as_bytes();
|
||||
// Hash an input all at once.
|
||||
let hash1 = blake3::hash(data).to_hex();
|
||||
println!("\nBlake3 Hash: {}", hash1);
|
||||
|
||||
//let sttring = CString::new(hash1).unwrap();
|
||||
let e_str = CString::new(format!("{}", hash1)).unwrap();
|
||||
return e_str.into_raw();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// Create a new wallet and return the seed for the newly created wallet.
|
||||
|
||||
Reference in New Issue
Block a user