using System;
using System.Text;
using System.Security.Cryptography;
using System.IO;
using Com.Bocom.OpenApi.Security.Sign;

namespace Com.Bocom.OpenApi
{
    namespace Security
    {
        namespace Crypt
        {
            public class RSACryptor
            {
                /// <summary>
                /// 类名：RSAFromPkcs8
                /// 功能：RSA加密、解密、签名、验签
                /// 详细：该类对Java生成的密钥进行解密和签名以及验签专用类，不需要修改
                /// 版本：3.0
                /// 日期：2013-07-08
                /// 说明：
                /// 以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
                /// </summary>
                public sealed class RSAFromPkcs8
                {
                    /// <summary>
                    /// 签名(SHA256)
                    /// </summary>
                    /// <param name="content">待签名字符串</param>
                    /// <param name="privateKey">私钥</param>
                    /// <param name="charset">编码格式</param>
                    /// <returns>签名后字符串</returns>
                    public static string SignWithRSASHA256(string content, string privateKey, string charset)
                    {
                        byte[] Data = Encoding.GetEncoding(charset).GetBytes(content);
                        RSACryptoServiceProvider rsa = DecodePemPrivateKey(privateKey);


                        SHA256CryptoServiceProvider sh = new SHA256CryptoServiceProvider();
                        byte[] signData = rsa.SignData(Data, "SHA256");
                        return Convert.ToBase64String(signData);
                    }


                    /// <summary>
                    /// 验签
                    /// </summary>
                    /// <param name="content">待验签字符串</param>
                    /// <param name="signedString">签名</param>
                    /// <param name="publicKey">公钥</param>
                    /// <param name="input_charset">编码格式</param>
                    /// <returns>true(通过)，false(不通过)</returns>
                    public static bool VerifySHA256(string content, string signedString, string publicKey,
                        string input_charset)
                    {
                        bool result;
                        byte[] Data = Encoding.GetEncoding(input_charset).GetBytes(content);
                        byte[] data = Convert.FromBase64String(signedString);


                        RSACryptoServiceProvider rsaPub = DecodePemPublicKey(publicKey);


                        //RSACryptoServiceProvider rsaPub = new RSACryptoServiceProvider();
                        //RSAParameters paraPub = ConvertFromPublicKey(publicKey);
                        //rsaPub.ImportParameters(paraPub);


                        SHA256CryptoServiceProvider sh = new SHA256CryptoServiceProvider();
                        result = rsaPub.VerifyData(Data, "SHA256", data);
                        return result;
                    }

                    /// <summary>
                    /// 加密
                    /// </summary>
                    /// <param name="resData">需要加密的字符串</param>
                    /// <param name="publicKey">公钥</param>
                    /// <param name="input_charset">编码格式</param>
                    /// <returns>明文</returns>
                    public string EncryptData(string content, string encryptKey, string charset)
                    {
                        RSACryptoServiceProvider rsa = DecodePemPublicKey(encryptKey);

                        byte[] cipherBytes = rsa.Encrypt(Encoding.GetEncoding(charset).GetBytes(content), false);

                        return Convert.ToBase64String(cipherBytes);
                    }


                    /// <summary>
                    /// 解密
                    /// </summary>
                    /// <param name="resData">加密字符串</param>
                    /// <param name="privateKey">私钥</param>
                    /// <param name="input_charset">编码格式</param>
                    /// <returns>明文</returns>//content, encryptKey, charset
                    public string DecryptData(string content, string encryptKey, string charset)
                    {
                        RSACryptoServiceProvider rsa = DecodePemPrivateKey(encryptKey);

                        byte[] cipherBytes = rsa.Decrypt(Convert.FromBase64String(content), false);

                        return Encoding.GetEncoding(charset).GetString(cipherBytes);
                    }

                    #region 内部方法

                    private static string encrypt(byte[] data, string publicKey, string input_charset)
                    {
                        RSACryptoServiceProvider rsa = DecodePemPublicKey(publicKey);
                        SHA1 sh = new SHA1CryptoServiceProvider();
                        byte[] result = rsa.Encrypt(data, false);

                        return Convert.ToBase64String(result);
                    }


                    private static string decrypt(byte[] data, string privateKey, string input_charset)
                    {
                        string result = "";
                        RSACryptoServiceProvider rsa = DecodePemPrivateKey(privateKey);
                        SHA1 sh = new SHA1CryptoServiceProvider();
                        byte[] source = rsa.Decrypt(data, false);
                        char[] asciiChars =
                            new char[Encoding.GetEncoding(input_charset).GetCharCount(source, 0, source.Length)];
                        Encoding.GetEncoding(input_charset).GetChars(source, 0, source.Length, asciiChars, 0);
                        result = new string(asciiChars);
                        //result = ASCIIEncoding.ASCII.GetString(source);
                        return result;
                    }


                    private static RSACryptoServiceProvider DecodePemPublicKey(string pemstr)
                    {
                        byte[] pkcs8publickkey;
                        pkcs8publickkey = Convert.FromBase64String(pemstr);
                        if (pkcs8publickkey != null)
                        {
                            RSACryptoServiceProvider rsa = DecodeRSAPublicKey(pkcs8publickkey);
                            return rsa;
                        }

                        return null;
                    }

                    private static RSACryptoServiceProvider DecodePemPrivateKey(string pemstr)
                    {
                        byte[] pkcs8privatekey;
                        pkcs8privatekey = Convert.FromBase64String(pemstr);
                        if (pkcs8privatekey != null)
                        {
                            RSACryptoServiceProvider rsa = DecodePrivateKeyInfo(pkcs8privatekey);
                            return rsa;
                        }

                        return null;
                    }


                    private static RSACryptoServiceProvider DecodePrivateKeyInfo(byte[] pkcs8)
                    {
                        byte[] SeqOID =
                            {0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00};
                        byte[] seq = new byte[15];


                        MemoryStream mem = new MemoryStream(pkcs8);
                        int lenstream = (int) mem.Length;
                        BinaryReader
                            binr = new BinaryReader(mem); //wrap Memory Stream with BinaryReader for easy reading
                        byte bt;
                        ushort twobytes;


                        try
                        {
                            twobytes = binr.ReadUInt16();
                            if (twobytes == 0x8130
                            ) //data read as little endian order (actual data order for Sequence is 30 81)
                                binr.ReadByte(); //advance 1 byte
                            else if (twobytes == 0x8230)
                                binr.ReadInt16(); //advance 2 bytes
                            else
                                return null;


                            bt = binr.ReadByte();
                            if (bt != 0x02)
                                return null;


                            twobytes = binr.ReadUInt16();


                            if (twobytes != 0x0001)
                                return null;


                            seq = binr.ReadBytes(15); //read the Sequence OID
                            if (!CompareBytearrays(seq, SeqOID)) //make sure Sequence for OID is correct
                                return null;


                            bt = binr.ReadByte();
                            if (bt != 0x04) //expect an Octet string
                                return null;


                            bt = binr
                                .ReadByte(); //read next byte, or next 2 bytes is  0x81 or 0x82; otherwise bt is the byte count
                            if (bt == 0x81)
                                binr.ReadByte();
                            else if (bt == 0x82)
                                binr.ReadUInt16();
                            //------ at this stage, the remaining sequence should be the RSA private key


                            byte[] rsaprivkey = binr.ReadBytes((int) (lenstream - mem.Position));
                            RSACryptoServiceProvider rsacsp = DecodeRSAPrivateKey(rsaprivkey);
                            return rsacsp;
                        }


                        catch (Exception)
                        {
                            return null;
                        }


                        finally
                        {
                            binr.Close();
                        }
                    }


                    private static bool CompareBytearrays(byte[] a, byte[] b)
                    {
                        if (a.Length != b.Length)
                            return false;
                        int i = 0;
                        foreach (byte c in a)
                        {
                            if (c != b[i])
                                return false;
                            i++;
                        }

                        return true;
                    }


                    private static RSACryptoServiceProvider DecodeRSAPublicKey(byte[] publickey)
                    {
                        // encoded OID sequence for  PKCS #1 rsaEncryption szOID_RSA_RSA = "1.2.840.113549.1.1.1"
                        byte[] SeqOID =
                            {0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00};
                        byte[] seq = new byte[15];
                        // ---------  Set up stream to read the asn.1 encoded SubjectPublicKeyInfo blob  ------
                        MemoryStream mem = new MemoryStream(publickey);
                        BinaryReader
                            binr = new BinaryReader(mem); //wrap Memory Stream with BinaryReader for easy reading
                        byte bt;
                        ushort twobytes;


                        try
                        {
                            twobytes = binr.ReadUInt16();
                            if (twobytes == 0x8130
                            ) //data read as little endian order (actual data order for Sequence is 30 81)
                                binr.ReadByte(); //advance 1 byte
                            else if (twobytes == 0x8230)
                                binr.ReadInt16(); //advance 2 bytes
                            else
                                return null;


                            seq = binr.ReadBytes(15); //read the Sequence OID
                            if (!CompareBytearrays(seq, SeqOID)) //make sure Sequence for OID is correct
                                return null;


                            twobytes = binr.ReadUInt16();
                            if (twobytes == 0x8103
                            ) //data read as little endian order (actual data order for Bit string is 03 81)
                                binr.ReadByte(); //advance 1 byte
                            else if (twobytes == 0x8203)
                                binr.ReadInt16(); //advance 2 bytes
                            else
                                return null;


                            bt = binr.ReadByte();
                            if (bt != 0x00) //expect null byte next
                                return null;


                            twobytes = binr.ReadUInt16();
                            if (twobytes == 0x8130
                            ) //data read as little endian order (actual data order for Sequence is 30 81)
                                binr.ReadByte(); //advance 1 byte
                            else if (twobytes == 0x8230)
                                binr.ReadInt16(); //advance 2 bytes
                            else
                                return null;


                            twobytes = binr.ReadUInt16();
                            byte lowbyte = 0x00;
                            byte highbyte = 0x00;


                            if (twobytes == 0x8102
                            ) //data read as little endian order (actual data order for Integer is 02 81)
                                lowbyte = binr.ReadByte(); // read next bytes which is bytes in modulus
                            else if (twobytes == 0x8202)
                            {
                                highbyte = binr.ReadByte(); //advance 2 bytes
                                lowbyte = binr.ReadByte();
                            }
                            else
                                return null;

                            byte[] modint =
                            {
                                lowbyte, highbyte, 0x00, 0x00
                            }; //reverse byte order since asn.1 key uses big endian order
                            int modsize = BitConverter.ToInt32(modint, 0);


                            byte firstbyte = binr.ReadByte();
                            binr.BaseStream.Seek(-1, SeekOrigin.Current);


                            if (firstbyte == 0x00)
                            {
                                //if first byte (highest order) of modulus is zero, don't include it
                                binr.ReadByte(); //skip this null byte
                                modsize -= 1; //reduce modulus buffer size by 1
                            }


                            byte[] modulus = binr.ReadBytes(modsize); //read the modulus bytes


                            if (binr.ReadByte() != 0x02) //expect an Integer for the exponent data
                                return null;
                            int expbytes =
                                (int) binr
                                    .ReadByte(); // should only need one byte for actual exponent data (for all useful values)
                            byte[] exponent = binr.ReadBytes(expbytes);


                            // ------- create RSACryptoServiceProvider instance and initialize with public key -----
                            RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
                            RSAParameters RSAKeyInfo = new RSAParameters();
                            RSAKeyInfo.Modulus = modulus;
                            RSAKeyInfo.Exponent = exponent;
                            RSA.ImportParameters(RSAKeyInfo);
                            return RSA;
                        }
                        catch (Exception)
                        {
                            return null;
                        }


                        finally
                        {
                            binr.Close();
                        }
                    }


                    private static RSACryptoServiceProvider DecodeRSAPrivateKey(byte[] privkey)
                    {
                        byte[] MODULUS, E, D, P, Q, DP, DQ, IQ;


                        // ---------  Set up stream to decode the asn.1 encoded RSA private key  ------
                        MemoryStream mem = new MemoryStream(privkey);
                        BinaryReader
                            binr = new BinaryReader(mem); //wrap Memory Stream with BinaryReader for easy reading
                        byte bt;
                        ushort twobytes;
                        int elems;
                        try
                        {
                            twobytes = binr.ReadUInt16();
                            if (twobytes == 0x8130
                            ) //data read as little endian order (actual data order for Sequence is 30 81)
                                binr.ReadByte(); //advance 1 byte
                            else if (twobytes == 0x8230)
                                binr.ReadInt16(); //advance 2 bytes
                            else
                                return null;


                            twobytes = binr.ReadUInt16();
                            if (twobytes != 0x0102) //version number
                                return null;
                            bt = binr.ReadByte();
                            if (bt != 0x00)
                                return null;


                            //------  all private key components are Integer sequences ----
                            elems = GetIntegerSize(binr);
                            MODULUS = binr.ReadBytes(elems);


                            elems = GetIntegerSize(binr);
                            E = binr.ReadBytes(elems);


                            elems = GetIntegerSize(binr);
                            D = binr.ReadBytes(elems);


                            elems = GetIntegerSize(binr);
                            P = binr.ReadBytes(elems);


                            elems = GetIntegerSize(binr);
                            Q = binr.ReadBytes(elems);


                            elems = GetIntegerSize(binr);
                            DP = binr.ReadBytes(elems);


                            elems = GetIntegerSize(binr);
                            DQ = binr.ReadBytes(elems);


                            elems = GetIntegerSize(binr);
                            IQ = binr.ReadBytes(elems);


                            // ------- create RSACryptoServiceProvider instance and initialize with public key -----
                            RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
                            RSAParameters RSAparams = new RSAParameters();
                            RSAparams.Modulus = MODULUS;
                            RSAparams.Exponent = E;
                            RSAparams.D = D;
                            RSAparams.P = P;
                            RSAparams.Q = Q;
                            RSAparams.DP = DP;
                            RSAparams.DQ = DQ;
                            RSAparams.InverseQ = IQ;
                            RSA.ImportParameters(RSAparams);
                            return RSA;
                        }
                        catch (Exception)
                        {
                            return null;
                        }
                        finally
                        {
                            binr.Close();
                        }
                    }


                    private static int GetIntegerSize(BinaryReader binr)
                    {
                        byte bt;
                        byte lowbyte;
                        byte highbyte;
                        int count;
                        bt = binr.ReadByte();
                        if (bt != 0x02) //expect integer
                            return 0;
                        bt = binr.ReadByte();


                        if (bt == 0x81)
                            count = binr.ReadByte(); // data size in next byte
                        else if (bt == 0x82)
                        {
                            highbyte = binr.ReadByte(); // data size in next 2 bytes
                            lowbyte = binr.ReadByte();
                            byte[] modint = {lowbyte, highbyte, 0x00, 0x00};
                            count = BitConverter.ToInt32(modint, 0);
                        }
                        else
                        {
                            count = bt; // we already have the data size
                        }


                        while (binr.ReadByte() == 0x00)
                        {
                            //remove high order zeros in data
                            count -= 1;
                        }

                        binr.BaseStream.Seek(-1,
                            SeekOrigin.Current); //last ReadByte wasn't a removed zero, so back up a byte
                        return count;
                    }

                    #endregion


                    #region 解析.net 生成的Pem

                    private static RSAParameters ConvertFromPublicKey(string pemFileConent)
                    {
                        byte[] keyData = Convert.FromBase64String(pemFileConent);
                        if (keyData.Length < 162)
                        {
                            throw new ArgumentException("pem file content is incorrect.");
                        }

                        byte[] pemModulus = new byte[128];
                        byte[] pemPublicExponent = new byte[3];
                        Array.Copy(keyData, 29, pemModulus, 0, 128);
                        Array.Copy(keyData, 159, pemPublicExponent, 0, 3);
                        RSAParameters para = new RSAParameters();
                        para.Modulus = pemModulus;
                        para.Exponent = pemPublicExponent;
                        return para;
                    }


                    private static RSAParameters ConvertFromPrivateKey(string pemFileConent)
                    {
                        byte[] keyData = Convert.FromBase64String(pemFileConent);
                        if (keyData.Length < 609)
                        {
                            throw new ArgumentException("pem file content is incorrect.");
                        }


                        int index = 11;
                        byte[] pemModulus = new byte[128];
                        Array.Copy(keyData, index, pemModulus, 0, 128);


                        index += 128;
                        index += 2; //141
                        byte[] pemPublicExponent = new byte[3];
                        Array.Copy(keyData, index, pemPublicExponent, 0, 3);


                        index += 3;
                        index += 4; //148
                        byte[] pemPrivateExponent = new byte[128];
                        Array.Copy(keyData, index, pemPrivateExponent, 0, 128);


                        index += 128;
                        index += ((int) keyData[index + 1] == 64 ? 2 : 3); //279
                        byte[] pemPrime1 = new byte[64];
                        Array.Copy(keyData, index, pemPrime1, 0, 64);


                        index += 64;
                        index += ((int) keyData[index + 1] == 64 ? 2 : 3); //346
                        byte[] pemPrime2 = new byte[64];
                        Array.Copy(keyData, index, pemPrime2, 0, 64);


                        index += 64;
                        index += ((int) keyData[index + 1] == 64 ? 2 : 3); //412/413
                        byte[] pemExponent1 = new byte[64];
                        Array.Copy(keyData, index, pemExponent1, 0, 64);


                        index += 64;
                        index += ((int) keyData[index + 1] == 64 ? 2 : 3); //479/480
                        byte[] pemExponent2 = new byte[64];
                        Array.Copy(keyData, index, pemExponent2, 0, 64);


                        index += 64;
                        index += ((int) keyData[index + 1] == 64 ? 2 : 3); //545/546
                        byte[] pemCoefficient = new byte[64];
                        Array.Copy(keyData, index, pemCoefficient, 0, 64);


                        RSAParameters para = new RSAParameters();
                        para.Modulus = pemModulus;
                        para.Exponent = pemPublicExponent;
                        para.D = pemPrivateExponent;
                        para.P = pemPrime1;
                        para.Q = pemPrime2;
                        para.DP = pemExponent1;
                        para.DQ = pemExponent2;
                        para.InverseQ = pemCoefficient;
                        return para;
                    }

                    #endregion
                }

                public static void ProKey(string path)
                {
                    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    using (StreamWriter writer = new StreamWriter(path + "yourname.pri"))
                    {
                        string privateKey = rsa.ToXmlString(true);

                        writer.WriteLine(RSASignature.RSAPrivateKeyDotNet2Java(privateKey));
                    }

                    using (StreamWriter writer = new StreamWriter(path + "yourname.pub"))
                    {
                        string publicKey = rsa.ToXmlString(false);
                        writer.WriteLine(RSASignature.RSAPublicKeyDotNet2Java(publicKey));
                    }
                }


                /* static void Main(string[] args)
                 {
                     RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
         
                     string privateKey = rsa.ToXmlString(true);
         
                     string publicKey = rsa.ToXmlString(false);
         
                     //string pr = BocomSignature.RSAPrivateKeyDotNet2Java(privateKey);
         
                     //string pu = BocomSignature.RSAPublicKeyDotNet2Java(publicKey);
         
                     string pr = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDkcFdmrJ/cwLE3u3dreROlM0/YbAi0g7m6o5YCfISOVqVPE6/WKRS0SVCFonFSb3BbddCv8fWUxQOyPkhccsxZN4tR4xEAVj6YOqb0JGMgEg3qdyGqdPlFK2FtsWvqhx23PAbfuruJNWWF+S27Ek0BV9/PgF5Hqg5NLAPawHkK8Vo4vaHntPBCLxrfidqWFMUR4nNc/zXoQxQtxTsoYLdTUjWglU9Ce5AcS0UvYbD0d7FrdaQ0XHwbNCWhFrX68c1eMxMNoSs+YaMgPb7dFwtLcO3uHGLzTOlX21eDokfBMvcc8+KJtqdpsYrQ8s4pb7OIO06oq/XH+wNeTHaFnVLnAgMBAAECggEBAMKzhar7Yt3SVrm7zJMLhVT+oQVDP0AsLbcICqlf29M9wnPdwbb1GLJ48mqUA6ZRWSB7ED2GKtx79ySKtT4mkklQcCyBLlJtL7ir9PSNtvb0rGu00jrorDTqPoYx/FrOguNUBD/YdlMB8d/4e6PAe2Wzsgy3yqOmK75Wz4o5FnHdm73Aa8IhO8TpKLeIQVYtxMizRVIyMWHfvPSTYS4cyQQyUUUSlCRjv9oa6lEpIvCZ0t5ZJ+PP4Mh2JWErf710mKNFGJTIkTYkM95kNtWeUPnpOAUN+MNZ5OjYFjIAzRiRURH3EnGVLriyYeJTOAELMZkyNu5zbLKgewwsi15kvcECgYEA9/+CRYvQi8VkHrTuKUrgfdKQyh6lQnXoI2jVDfMvziPOP6ibym68jqoYMPsEWLEBsiZixvldg16iHn8YdXXbUmzoWsm+IQjNHGminBjh5vs+GtdIDZ2qP54L27NuLA454wihVh1uC/Vb+kzYxhloGJ7dWlFCI0pD8LdCpOPBYdECgYEA689FYa6TMx5COCfH0saJxnh82gcqHXIJ2B7GCojlYt7IlKer0kkQQxN24O3VgLJGi/NI0uxeyDphSt0+T0qPi7CLNDgJ/JXRV98vFuD3LSFJGTe+s8HyvKHRd8n5pqRJd3+JpOJhoRnu38DzS0bDoFq+THrIoY/sOoNK3RXpHzcCgYAYZWM8Ui+2wDlEKApRt5Lz7bXenDsnmY+3hAWJdMXcInuUmZKRzGjyI9tzXg4kZ21CSDJpXniLhtCt7VTLoUdtCVemLrhsaYA77kxXzL7USRzn6Qumgz8POQ3zk+gfn1qkceHlJcoAlSdyLQMaIb+yxFYEH4BBFnougOimbd1FMQKBgQDB706FfrkLIoidfIIH5EbtVqx/98J4QxC7kNuZUGsvPEBEmf1izbo1IC314URlOrlwYh5zcfilvfXER172gUC7Ru/Fe40jEegA18n3i/9dO3HN7p3FYu4Kmx8V4KOUnKrbP6XpWFGo2BYwKZUuRL2hBOBbL+QPk7lZih8o4ts+UwKBgFW40/4QRJ/aw20eXSjdN4aIUtFiDM/LRQhYsW3evbXqxkBpK4MsTaROFmgb0VsiJpA1gDLRuRy6i2tEbgyl7zyFakWF+JZTP2ASxw8nBMpG4fC4IHIodjoCGIt9gFto6qCknS9YE88T1v/bhhRuzRswl/00aTZIXL+HMfwxwvWm";
         
                     string pu = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5HBXZqyf3MCxN7t3a3kTpTNP2GwItIO5uqOWAnyEjlalTxOv1ikUtElQhaJxUm9wW3XQr/H1lMUDsj5IXHLMWTeLUeMRAFY+mDqm9CRjIBIN6nchqnT5RSthbbFr6ocdtzwG37q7iTVlhfktuxJNAVffz4BeR6oOTSwD2sB5CvFaOL2h57TwQi8a34nalhTFEeJzXP816EMULcU7KGC3U1I1oJVPQnuQHEtFL2Gw9Hexa3WkNFx8GzQloRa1+vHNXjMTDaErPmGjID2+3RcLS3Dt7hxi80zpV9tXg6JHwTL3HPPiibanabGK0PLOKW+ziDtOqKv1x/sDXkx2hZ1S5wIDAQAB";
         
                     Console.WriteLine("pr: " + pr);
         
                     Console.WriteLine("pu: " + pu);
         
                     string content = "aaawwwwgsagas42352346";
         
                     string sign = RSACryptor.RSAFromPkcs8.signWithRSASHA256(content, pr, "UTF-8");
         
                     Console.WriteLine("sign: " + sign);
         
                     Boolean b = RSACryptor.RSAFromPkcs8.verifySHA256(content, sign, pu, "UTF-8");
         
         
                     Console.WriteLine("verifySHA256: " + b);
         
                 }*/
            }
        }
    }
}