public
partial
class
Form1 : Form {
static
char
?[] Charcode =
new
char
?[25];
static
int
[] intNumber =
new
int
[25];
static
int
[] intCode =
new
int
[256];
static
void
SetIntCode() {
for
(
int
i = 1; i <= intCode.Length / 10; i++) {
for
(
int
j = 0; j < 10; j++) {
intCode[(i - 1) * 10 + j] = j;
}
}
}
static
public
string
GetCode(
string
code) {
if
(!
string
.IsNullOrEmpty(code)) {
SetIntCode();
for
(
int
i = 1; i < Charcode.Length; i++) {
if
(i - 1 < code.Length) {
Charcode[i] = code[i - 1];
}
}
for
(
int
j = 1; j < intNumber.Length; j++) {
if
(j < Charcode.Length && Charcode[j].HasValue) {
intNumber[j] = intCode[(
int
)Charcode[j].Value] + (
int
)Charcode[j].Value;
}
}
string
text =
""
;
for
(
int
k = 1; k < intNumber.Length; k++) {
if
((48 <= intNumber[k] && intNumber[k] <= 57) ||
(65 <= intNumber[k] && intNumber[k] <= 90) ||
(97 <= intNumber[k] && intNumber[k] <= 122)) {
text += (
char
)intNumber[k];
}
else
if
(intNumber[k] > 122) {
int
value = intNumber[k] - 10;
if
(0 <= value && value <= 0x10FFFF) {
text += (
char
)value;
}
}
else
{
int
value = intNumber[k] - 9;
if
(0 <= value && value <= 0x10FFFF) {
text += (
char
)value;
}
}
}
return
text;
}
else
{
return
""
;
}
}
public
Form1() {
InitializeComponent();
}
private
static
string
GetMd5(
string
input) {
using
(MD5 md5 = MD5.Create()) {
byte
[] inputBytes = Encoding.ASCII.GetBytes(input);
byte
[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb =
new
StringBuilder();
for
(
int
i = 0; i < hashBytes.Length; i++) {
sb.Append(hashBytes[i].ToString(
"X2"
));
}
return
sb.ToString();
}
}
public
static
string
GenerateActivationCode(
string
currentCode) {
DateTime now = DateTime.Now;
DateTime futureDate = now.AddYears(1);
long
nowBinary = now.ToBinary();
long
futureBinary = futureDate.ToBinary();
string
part3 =
"extra_part_3"
;
string
part4 =
"extra_part_4"
;
string
part5 =
"extra_part_5"
;
string
part6 =
"extra_part_6"
;
string
part7 =
"extra_part_7"
;
string
activationCode = $
"{currentCode}[{nowBinary}[{futureBinary}[{part3}[{part4}[{part5}[{part6}[{part7}"
;
return
activationCode;
}
private
void
button1_Click(
object
sender, EventArgs e) {
var
tmp_string = GetCode(
""
);
textBox2.Text = GenerateActivationCode(tmp_string );
}
}