-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLicense.cs
101 lines (100 loc) · 4.01 KB
/
License.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MetroFramework.Forms;
using Microsoft.Win32;
namespace EnjoyPlayer
{
public partial class License : MetroForm
{
public License()
{
InitializeComponent();
}
#region License
private void metroButton1_Click(object sender, EventArgs e)
{
LicenseCheck();
//bunifuCustomLabel1.Text = checkMachineType().ToString();
}
public static bool checkMachineType()
{
RegistryKey winLogonKey = Registry.CurrentUser.OpenSubKey(@"Software\EnjoyStream", true);
return (winLogonKey.GetValueNames().Contains("KEY"));
}
void LicenseCheck()
{
try
{
Form1 main = new Form1();
RegistryKey license = Registry.LocalMachine.OpenSubKey(@"Software\EnjoyStream", false);
var licensekey = license.GetValue("LICENSE").ToString();
RegistryKey call = Registry.CurrentUser.OpenSubKey(@"Software\EnjoyStream", false);
var callkey = call.GetValue("CALL").ToString();
if (checkMachineType().ToString() == "True")
{
RegistryKey winLogonKey = Registry.CurrentUser.OpenSubKey(@"Software\EnjoyStream", true);
var key = winLogonKey.GetValue("KEY").ToString();
if (licensekey.Equals(AesOperation.DecryptString(key, callkey).ToString()))
{
this.Hide();
main.Closed += (s, args) => this.Close();
main.Show();
}
else
{
MessageBox.Show("Invalid product key!\n (Bad license)!", "EnjoyStream", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
}
}
else if (licensekey.Equals(AesOperation.DecryptString(keyinput.Text, callkey).ToString()))
{
//WRITE THE KEY
RegistryKey winkey = Registry.CurrentUser.CreateSubKey(@"Software\EnjoyStream");
winkey.SetValue("KEY", keyinput.Text.ToString());
winkey.Close();
Hide();
main.Closed += (s, args) => this.Close();
main.Show();
}
}
catch
{
MessageBox.Show("Invalid product key!\n", "EnjoyStream", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
}
}
private void License_Shown_1(object sender, EventArgs e)
{
try
{
Form1 main = new Form1();
RegistryKey license = Registry.CurrentUser.OpenSubKey(@"Software\EnjoyStream", false);
var licensekey = license.GetValue("LICENSE").ToString();
RegistryKey call = Registry.CurrentUser.OpenSubKey(@"Software\EnjoyStream", false);
var callkey = call.GetValue("CALL").ToString();
if (checkMachineType().ToString() == "True")
{
RegistryKey winLogonKey = Registry.CurrentUser.OpenSubKey(@"Software\EnjoyStream", true);
var key = winLogonKey.GetValue("KEY").ToString();
if (licensekey.Equals(AesOperation.DecryptString(key, callkey).ToString()))
{
Hide();
main.Closed += (s, args) => this.Close();
main.Show();
}
}
}
catch
{
MessageBox.Show("Error! Please contact with the developer!\n", "EnjoyStream", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
}
}