Esempio n. 1
0
        public static Boolean Verify(this Models.PacketData _Packet)
        {
            var _Signature = NormalizeChars(_Packet.Signature);
            var _PublicKey = NormalizeChars(_Packet.PublicKey);

            var _BlockJSON = JsonConvert.SerializeObject(_Packet);
            var _BlockHash = Hashing.GetHashForString(_BlockJSON);

            return(RSA.Verify(_BlockHash, _Signature, _PublicKey));
        }
Esempio n. 2
0
        public static Models.PacketData SignPacket(this Models.PacketData _Packet, String _Key)
        {
            var _Timestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            _Packet.Timestamp = (uint)_Timestamp;
            _Packet.PublicKey = SoftConfigs._LocalConfig.PublicKey.ToCharArray();

            var _BlockJSON = JsonConvert.SerializeObject(_Packet);
            var _BlockHash = Hashing.GetHashForString(_BlockJSON);

            _Packet.Signature = RSA.Sign(_BlockHash, _Key).ToCharArray();

            return(_Packet);
        }