Biginteger chiel via UDP



  • There's a class that I'm showing in the xml and passing through. UDP♪ On the side of the receiver, the numbers are empty, that's just zero. Although the text of the communication is retained) I think there's a problem with the transfer of large numbers through. UDP

    PS. I'm writing a digital signature verification program for Gamal. I want to send an open key and sign to UDP.

    [Serializable]
    public class PublicKeyAndSignature // Открытый ключ и подпись
    {
        public string M { get; set; } // Message
        public BigInteger r { get; set; } // 
        public BigInteger s { get; set; } //
        public BigInteger p { get; set; }
        public BigInteger g { get; set; }
        public BigInteger y { get; set; }
    }
    

    XmlSerializer xml_ser = new XmlSerializer(typeof(PublicKeyAndSignature));
    MemoryStream str = new MemoryStream();

            var key = Gamal.Encode("Привет");
    
            xml_ser.Serialize(str, key);
            buffer = str.ToArray();
            str.Close();
    
            try
            {
                s.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(DoSend), s);
            }
    



  • It's best to send data through the binary show.

      var key = Gamal.Encode("Привет",p,g,x,k); // Текст для подписи
      MemoryStream str = new MemoryStream();
      MemoryStream stream = ElgamalLib.Gamal.SerializeToStream(key);
      buffer = stream.ToArray();
      str.Close();
    

    try
    {
    s.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(DoSend), s);
    }

    public static MemoryStream SerializeToStream(object o)
    {
    MemoryStream stream = new MemoryStream();
    IFormatter formatter = new BinaryFormatter();
    formatter.Serialize(stream, o);
    return stream;
    }

        public static object DeserializeFromStream(MemoryStream stream)
        {
            IFormatter formatter = new BinaryFormatter();
            stream.Seek(0, SeekOrigin.Begin);
            object o = formatter.Deserialize(stream);
            return o;
        }
    




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2