/// <summary> /// 设置用户公钥私钥 /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> private user SetUserKey(string username, string password) { TanSM3Ex sm3 = new TanSM3Ex(); string digest = sm3.TanGetDigest(password); TanSM2Ex sm2 = new TanSM2Ex(); sm2.TanGenSM2KeyPair(); string pubkey = sm2.publicKey; string prvkey = sm2.privateKey; user u = getUser(username); if (u == null) { u = new user(); } u.username = username; u.password = digest; u.pubkey = pubkey; u.prikey = prvkey; return(u); }
/// <summary> /// 设置用户公钥私钥并重置密码 /// </summary> /// <param name="id">用户id</param> /// <param name="password">用户密码</param> /// <returns></returns> public user SetUserKey(string password, string id) { TanSM3Ex sm3 = new TanSM3Ex(); string digest = sm3.TanGetDigest(password); TanSM2Ex sm2 = new TanSM2Ex(); sm2.TanGenSM2KeyPair(); string pubkey = sm2.publicKey; string prvkey = sm2.privateKey; user u = getEntityById(Convert.ToInt32(id)); if (u.password != digest) { u.password = digest; } if (u == null) { u = new user() as user; } u.pubkey = pubkey; u.prikey = prvkey; return(u as user); }