Ejemplo n.º 1
0
        /**
         * 解密算法
         *
         * @param cryptograph
         *            :密文,带","
         * @param d
         *            私钥
         * @param n
         * @param numBit
         *            位数
         * @return
         * @
         */
        public static String decrypt(String cryptograph, BigInteger d,
                                     BigInteger n, int numBit)
        {
            String[] chs = cryptograph.Split(' ');
            if (chs == null || chs.GetLength(0) <= 0)
            {
                throw new Exception("密文不符合要求!!!");
            }
            int numeroToken = chs.GetLength(0);

            BigInteger[] StringToByte = new BigInteger[numeroToken];
            for (int i = 0; i < numeroToken; i++)
            {
                StringToByte[i] = new BigInteger(chs[i], 16);
            }
            byte[][] encodeM     = RSAUtil.dencodeRSA(StringToByte, d, n);
            byte[]   sendMessage = RSAUtil.StringToByte(encodeM);
            //String message = new String(sendMessage, "UTF-8");
            string message = System.Text.Encoding.Default.GetString(sendMessage);
            String result  = System.Web.HttpUtility.UrlDecode(message, Encoding.UTF8);//.UrlDecode.decode(message, "UTF-8");

            return(result);
        }