Ejemplo n.º 1
0
        private void WriteDongle(Lease lease)
        {
            string fullFileName = this.pathName + DongleGenerator.DONGLE;
            EnDec  enDec        = new EnDec();

            byte[]       bytesEncrypted = enDec.Encrypt(lease.ToString());
            FileStream   fs             = new FileStream(fullFileName, FileMode.CreateNew);
            BinaryWriter binaryWriter   = new BinaryWriter(fs);

            binaryWriter.Write(bytesEncrypted);
            binaryWriter.Close();
        }
Ejemplo n.º 2
0
        public Lease GetLease()
        {
            Lease  lease        = null;
            string fullFileName = this.pathName + DongleGenerator.DONGLE;

            if (File.Exists(fullFileName))
            {
                FileStream   fs             = new FileStream(fullFileName, FileMode.Open, FileAccess.Read);
                BinaryReader binaryReader   = new BinaryReader(fs);
                byte[]       bytesEncrypted = binaryReader.ReadBytes(1000);
                binaryReader.Close();
                EnDec  enDec           = new EnDec();
                string stringDecrypted = enDec.Decrypt(bytesEncrypted);
                lease = new Lease(stringDecrypted);
            }
            return(lease);
        }