コード例 #1
0
        private void dealtypeone(string[] message)
        {
            if (message.Length < 0)
            {
                throw new Exception("Deal type one message error, the length less than three.");
            }
            Message clientmessage = new Message();

            clientmessage.Number = message[1];
            string publickey = "";

            for (int i = 0; i < message.Length; i++)
            {
                if (message[i].Equals("-----BEGIN PUBLIC KEY-----"))
                {
                    for (int j = i; j < message.Length; j++)
                    {
                        publickey += message[j];
                        publickey += '\n';
                        if (message[j].Equals("-----END PUBLIC KEY-----"))
                        {
                            break;
                        }
                    }
                    break;
                }
            }
            ReadWriteRSA.writerrsa("ServerPublicKey.pem", publickey);
            MessageBox.Show("注册成功");
        }
コード例 #2
0
        public ClientRSA()
        {
            RSA    rsa         = new RSA();
            string privarename = "MasterPrivateKey.pem";
            string publicname  = "MasterPublicKey.pem";

            if (File.Exists(privarename) && File.Exists(publicname))
            {
                publickey  = ReadWriteRSA.readrsa(publicname);
                privatekey = ReadWriteRSA.readrsa(privarename);
            }
            else
            {
                generatekeys(rsa);
                publickey  = rsa.PublicKeyAsPEM;
                privatekey = rsa.PrivateKeyAsPEM;
            }
        }
コード例 #3
0
 public ServerRSA()
 {
     publickey = ReadWriteRSA.readrsa(Filename.ServerPublicKey);
 }