NetSeal_Helper.NetSeal.LicenseManager.LicenseReader.ReadLicenseFromV2 C# (CSharp) Method

ReadLicenseFromV2() private method

Reads a netseal license file
private ReadLicenseFromV2 ( string licensePath, string netsealId ) : NetSeal_Helper.NetSeal.LicenseManager.LicenseFile
licensePath string License File Path
netsealId string NetSeal ID
return NetSeal_Helper.NetSeal.LicenseManager.LicenseFile
        internal LicenseFile ReadLicenseFromV2(string licensePath, string netsealId)
        {
            if(!File.Exists(licensePath))
                throw new FileNotFoundException("License file not found");

            var licenseBytes = File.ReadAllBytes(licensePath);
            var decrypted = ProtectedData.Unprotect(licenseBytes, null, DataProtectionScope.CurrentUser);
            var licenseFile = default(LicenseFile);

            using (var memoryStream = new MemoryStream(decrypted))
            {
                using (var binaryReader = new BinaryReader(memoryStream))
                {
                    licenseFile.LicenseName = Path.GetFileName(licensePath);
                    licenseFile.ID = netsealId;
                    licenseFile.GUID = string.Empty;
                    licenseFile.Username = binaryReader.ReadString();
                    licenseFile.Sha1Password = binaryReader.ReadString(); //Real password, no encryption
                }
            }
            return licenseFile;
        }