示例#1
0
        /// <summary>
        /// 密码pinblock加密
        /// </summary>
        /// <param name="card"></param>
        /// <param name="pwd"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        public static string EncryptPin(string card, string pwd)
        {
            /** 生成PIN Block **/
            byte[] pinBlock = SecurityUtil.pin2PinBlockWithCardNO(pwd, card);
            PrintHexString(pinBlock);


            X509Certificate2 pc = new X509Certificate2(SDKConfig.EncryptCert);


            RSACryptoServiceProvider p = new RSACryptoServiceProvider();

            p = (RSACryptoServiceProvider)pc.PublicKey.Key;

            byte[] enBytes = p.Encrypt(pinBlock, false);

            return(Convert.ToBase64String(enBytes));


            // return SecurityUtil.EncryptPin(pwd, card, encoding);
        }
示例#2
0
        /// <summary>
        /// 密码pinblock加密[已无期,无法使用]
        /// </summary>
        /// <param name="card"></param>
        /// <param name="pwd"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        public static string EncryptPin(string card, string pwd, SDKConfig con)
        {
            /** 生成PIN Block **/
            byte[] pinBlock = SecurityUtil.pin2PinBlockWithCardNO(pwd, card);
            PrintHexString(pinBlock);

            //由于此方法没有使用,基础类修改后,不再是全局静态,此处为程序能编译通过,暂时这样处理
            //yfzw 2017-3-3
            X509Certificate2 pc = new X509Certificate2(con.EncryptCert);


            RSACryptoServiceProvider p = new RSACryptoServiceProvider();

            p = (RSACryptoServiceProvider)pc.PublicKey.Key;

            byte[] enBytes = p.Encrypt(pinBlock, false);

            return(Convert.ToBase64String(enBytes));


            // return SecurityUtil.EncryptPin(pwd, card, encoding);
        }