Beispiel #1
0
        public DataTable setuser(string ip, string port, string name, string pwd)
        {
            string res = "";
            string sql = "select * from TB_User u inner join TB_IPList IP on u.User_ID = ip.Sel_User where (ip.Sel_IP = @ip and ip.Sel_Port = @port) or u.User_Name = @name";

            SqlParameter[] para1 = { new SqlParameter("@ip", ip), new SqlParameter("@port", port), new SqlParameter("@name", name) };
            DataTable      dt    = new Models.SQLHelper().ExcuteQuery(sql, para1, CommandType.Text);

            if (dt.Rows.Count != 0)
            {
                return(new DataTable());
            }
            string[] keys = new Tools.Encrypt().CreateRSAKey();//创建秘钥
            sql = "insertuser";
            SqlParameter[] para2 =
            {
                new SqlParameter("@ip",    ip),
                new SqlParameter("@port",  port),
                new SqlParameter("@name",  name),
                new SqlParameter("pubkey", keys[0]),
                new SqlParameter("prikey", keys[1])
            };
            dt = new Models.SQLHelper().ExcuteQuery(sql, para2, CommandType.StoredProcedure);
            return(dt);
        }
Beispiel #2
0
        public string getpublickey(string id)
        {
            string res;
            string sql = "select User_PriKey from TB_User where User_ID = @id";//私钥是这里的公钥,用于解密

            SqlParameter[] paras = { new SqlParameter("@id", id) };
            DataTable      dt    = new Models.SQLHelper().ExcuteQuery(sql, paras, CommandType.Text);

            res = new Tools.jstodt().ToJson(dt);
            return(res);
        }