示例#1
0
        public void setValue2(TLVList tlvs)
        {
            tlvInit   = false;
            tlvValue  = null;
            tlvLength = 0;

            if (tlvs == null || secret == null)
            {
                return;
            }
            var Encoder = new MemoryStream();
            var os      = new BinaryWriter(Encoder);

            foreach (short or in order)
            {
                for (int i = 0; i < tlvs.Count(); i++)
                {
                    if (tlvs[i].tlvCode == or)
                    {
                        os.Write(tlvs[i].tlvValue);
                    }
                }
            }

            byte[] digest = hmacMd5(Encoder.ToArray(), Encoding.UTF8.GetBytes(secret));
            //BitConverter.GetBytes(this.secret));
            tlvValue  = digest;
            tlvLength = digest.Length;
            tlvInit   = true;
        }
示例#2
0
        public byte[] ToEncoding()
        {
            if (EncodedFile.Count() == 0)
            {
                return(null);
            }
            var encodeStream = new MemoryStream();
            var binaryWriter = new BinaryWriter(encodeStream);

            binaryWriter.Write(EncodedFile.GetEncodings());
            TLV cmMIC = new TLVCMMIC(EncodedFile);

            binaryWriter.Write(cmMIC.ToEncoding());
            EncodedFile.Add(cmMIC);
            binaryWriter.Write((new TLVCMTSMIC(EncodedFile, Secret).ToEncoding()));
            TLV EndOfBataMkr = new TLVSpecial();

            // Add EndOfDataMkr before making the MD5
            binaryWriter.Write(EndOfBataMkr.ToEncoding());
            return(encodeStream.ToArray());
        }