Пример #1
0
        /// <summary>解密数据</summary>
        /// <param name="nwkSkey"></param>
        /// <param name="appSkey"></param>
        /// <returns></returns>
        public Byte[] Decrypt(Byte[] nwkSkey, Byte[] appSkey)
        {
            var crypto = new LoRaMacCrypto();

            if (FPort == 0)
            {
                if (nwkSkey == null)
                {
                    throw new ArgumentNullException(nameof(nwkSkey));
                }

                return(crypto.PayloadDecrypt(Payload.ToArray(), nwkSkey, DevAddr, true, FCnt));
            }
            else
            {
                if (appSkey == null)
                {
                    throw new ArgumentNullException(nameof(appSkey));
                }

                return(crypto.PayloadDecrypt(Payload.ToArray(), appSkey, DevAddr, true, FCnt));
            }
        }
Пример #2
0
            private void Test3()
            {
                var crypto = new LoRaMacCrypto();

                //var buf = "C86B3BF3".ToHex();
                var buf = "58E1369B".ToHex();
                var key = "A499E0B73311D0782EC80C98FEC83B8E".ToHex();
                var rs  = crypto.PayloadDecrypt(buf, key, 0x77F7EEF0, true, 0x0142);

                var str = rs.ToHex();

                XTrace.WriteLine(str);
                //Debug.Assert(str == "B93747B2");
                Debug.Assert(str == "092200DB");
            }