NetSeal_Helper.NetSeal.LicenseManager.LicenseWriter.WriteLicenseV2 C# (CSharp) Method

WriteLicenseV2() private method

private WriteLicenseV2 ( string path, string netsealId, string username, string password ) : void
path string
netsealId string
username string
password string
return void
        internal void WriteLicenseV2(string path, string netsealId, string username, string password)
        {
            using (var memoryStream = new MemoryStream())
            {
                using (var binaryWriter = new BinaryWriter(memoryStream))
                {
                    binaryWriter.Write(username);
                    binaryWriter.Write(password);
                    var buffer = ProtectedData.Protect(memoryStream.ToArray(), null, DataProtectionScope.CurrentUser);
                    File.WriteAllBytes(path, buffer);
                }
            }
        }

Usage Example

Esempio n. 1
0
        private void exportLicenseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var folderDialog = new FolderBrowserDialog())
            {
                var result = folderDialog.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    var path = folderDialog.SelectedPath;
                    var licenseWriter = new LicenseWriter();

                    int counter = 0;
                    for (var index = 0; index < ltvLicenses.SelectedIndices.Count; index++)
                    {
                        var license = this.Licenses[ltvLicenses.SelectedIndices[index]];
                        licenseWriter.WriteLicenseV2(
                            path + "\\" + license.LicenseName,
                            license.ID,
                            license.Username,
                            license.Sha1Password);

                        counter++;
                    }
                    Logger.LogInformation("Exported " + counter + " licenses");
                }
            }
        }