2023-09-14 13:13:28 +08:00

62 lines
1.7 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//test.rs
//
// 测试在Rust侧生成钱包密钥对转换成C侧的数据结构。
// 测试钱包在C侧调用接口存储和重新读出钱包密钥
//
use rustwallet::{
generate_scrypt_hash, generate_sec_key, sign, sign_for_tran, wdecrypt, wencrypt, wget_address,
};
fn main() {
let msg = "a0f2022d15fd8072f12c76cc1596c4f1";
let key0 = "3f26e586111b5c4cab6a5dd5e0d13c3b13184ba74410ba064a3b485be4f9a2cd";
let key1 = "";
let key2 = "cd00eb0126aeed39762579ce94c90a04695ad17fbd5e79aa4e9fc4a34ba32a5";
// let private_key = generate_sec_key(
// msg.to_string(),
// key0.to_string(),
// None,
// Some(key2.to_string()),
// );
// println!("private_key=> {}", private_key);
// let address2 = wget_address(
// msg.to_string(),
// key0.to_string(),
// None,
// Some(key2.to_string()),
// );
// println!("address=> {}", address2);
// let message = "helloword";
// let msg_encrypt = wencrypt(
// msg.to_string(),
// key0.to_string(),
// None,
// Some(key2.to_string()),
// message.to_string(),
// );
// println!("msg_encrypt=> {}", msg_encrypt);
// let msg_decrypt = wdecrypt(
// msg.to_string(),
// key0.to_string(),
// None,
// Some(key2.to_string()),
// msg_encrypt,
// );
// println!("msg_decrypt=> {}", msg_decrypt);
let pass = "111111";
let salt = "9ded475b6bf63ee9c0150b127f6c093600e952da79ba848d6f4f9a93c3c27259";
let n: f32 = 8192f32;
let r: u32 = 8;
let p: u32 = 1;
let size: u32 = 32;
let hash = generate_scrypt_hash(pass.to_string(), salt.to_string(), n, r, p, size);
println!("scrypt hash => {}", hash);
}