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;
}