Dear All,
I have some code, for which I need additional code for Key Generation.
If any of you can help, it would be great.
Regards
Enscription Code
namespace ConsTech
{
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.Win32;
using System;
using System.Collections;
using System.Management;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
[StandardModule]
internal sealed class MdlKeyEncrypt
{
private static int[] aDecTab = new int[0x100];
private const string sEncTab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
public static bool CheckRegistration()
{
string str5 = Conversions.ToString(Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "UserName", "S"));
if (Strings.Trim(str5) != "")
{
str5 = DecodeStr64(str5);
}
string str = Conversions.ToString(Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "HardwareID", "S"));
if (Strings.Trim(str) != "")
{
str = DecodeStr64(str);
}
string str2 = Conversions.ToString(Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "Key", "S"));
if (Strings.Trim(str2) != "")
{
str2 = DecodeStr64(str2);
}
string str3 = Conversions.ToString(Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "KeyType", "S"));
if (Strings.Trim(str3) != "")
{
str3 = DecodeStr64(str3);
}
string str4 = Conversions.ToString(Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "RegSet", "S"));
if (Strings.Trim(str4) != "")
{
str4 = DecodeStr64(str4);
}
if (str5 == "")
{
return false;
}
return (GenerateSoftwareKEY(str5, str, 2) == str2);
}
private static string DecodeQuantum(byte[] d)
{
string str2 = "";
long num = SHL(d[0], 2) | (SHR(d[1], 4) & 3);
str2 = str2 + Conversions.ToString(Strings.Chr((int) num));
num = SHL((byte) (d[1] & 15), 4) | (SHR(d[2], 2) & 15);
str2 = str2 + Conversions.ToString(Strings.Chr((int) num));
num = (long) ((ulong) (SHL((byte) (d[2] & 3), 6) | d[3]));
return (str2 + Conversions.ToString(Strings.Chr((int) num)));
}
public static string DecodeStr64(string sEncoded)
{
byte[] d = new byte[4];
string str = "";
int index = 0;
MakeDecTab();
long num4 = Strings.Len(sEncoded);
for (long i = 1L; i <= num4; i += 1L)
{
byte num = (byte) Strings.Asc(Strings.Mid(sEncoded, (int) i, 1));
num = (byte) aDecTab[num];
if (num >= 0)
{
d[index] = num;
index++;
if (index == 4)
{
str = str + DecodeQuantum(d);
if (d[3] == 0x40)
{
str = Strings.Left(str, Strings.Len(str) - 1);
}
if (d[2] == 0x40)
{
str = Strings.Left(str, Strings.Len(str) - 1);
}
index = 0;
}
}
}
return str;
}
private static string EncodeQuantum(byte[] b)
{
string str2 = "";
int num = SHR(b[0], 2) & 0x3f;
str2 = str2 + Strings.Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", num + 1, 1);
num = SHL((byte) (b[0] & 3), 4) | (SHR(b[1], 4) & 15);
str2 = str2 + Strings.Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", num + 1, 1);
num = SHL((byte) (b[1] & 15), 2) | (SHR(b[2], 6) & 3);
str2 = str2 + Strings.Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", num + 1, 1);
num = b[2] & 0x3f;
return (str2 + Strings.Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", num + 1, 1));
}
public static string EncodeStr64(string sInput)
{
byte[] b = new byte[3];
string str2 = string.Empty;
long num3 = Strings.Len(sInput);
long num4 = num3 / 3L;
string str3 = "";
long num5 = num4 - 1L;
for (long i = 0L; i <= num5; i += 1L)
{
int num7;
int index = 0;
do
{
b[index] = (byte) Strings.Asc(Strings.Mid(sInput, (int) (((i * 3L) + index) + 1L), 1));
index++;
num7 = 2;
}
while (index <= num7);
str3 = str3 + EncodeQuantum(b);
}
long num6 = num3 % 3L;
if ((num6 <= 2L) && (num6 >= 0L))
{
switch (((int) num6))
{
case 0:
str2 = "";
break;
case 1:
b[0] = (byte) Strings.Asc(Strings.Mid(sInput, (int) num3, 1));
b[1] = 0;
b[2] = 0;
str2 = Strings.Left(EncodeQuantum(b), 2) + "==";
break;
case 2:
b[0] = (byte) Strings.Asc(Strings.Mid(sInput, (int) (num3 - 1L), 1));
b[1] = (byte) Strings.Asc(Strings.Mid(sInput, (int) num3, 1));
b[2] = 0;
str2 = Strings.Left(EncodeQuantum(b), 3) + "=";
break;
}
}
return (str3 + str2);
}
public static string GenerateSoftwareKEY(object KNamev, string KPass, int KType)
{
string str;
int num22;
try
{
int num7;
int num10;
int num23;
Label_0001:
ProjectData.ClearProjectError();
int num21 = -2;
Label_000A:
num23 = 2;
int[] numArray = new int[0x201];
Label_0019:
num23 = 3;
int[] numArray3 = new int[0x11];
Label_0025:
num23 = 4;
int[] numArray5 = new int[0x201];
Label_0034:
num23 = 5;
int[] numArray2 = new int[0x11];
Label_0040:
num23 = 6;
int[] numArray4 = new int[0x11];
Label_004C:
num23 = 7;
string str3 = string.Empty;
Label_0056:
num23 = 8;
string str4 = Versioned.TypeName(RuntimeHelpers.GetObjectValue(KNamev));
Label_0066:
num23 = 9;
str4 = Versioned.TypeName(RuntimeHelpers.GetObjectValue(KNamev)).ToString();
Label_007C:
num23 = 10;
string str5 = str4;
Label_0085:
num23 = 13;
if (str5 != "String")
{
goto Label_00B1;
}
Label_00A0:
num23 = 14;
str3 = Conversions.ToString(KNamev);
goto Label_02A4;
Label_00B1:
num23 = 0x10;
if (str5 != "TextBox")
{
goto Label_00F1;
}
Label_00CC:
num23 = 0x11;
str3 = Conversions.ToString(NewLateBinding.LateGet(KNamev, null, "Text", new object[0], null, null, null));
goto Label_02A4;
Label_00F1:
num23 = 0x13;
if (str5 != "Object")
{
goto Label_01B7;
}
Label_010F:
num23 = 20;
IEnumerator enumerator = ((IEnumerable) KNamev).GetEnumerator();
while (enumerator.MoveNext())
{
Control current = (Control) enumerator.Current;
Label_012F:
num23 = 0x15;
if (current.Text == "")
{
goto Label_0169;
}
Label_0150:
num23 = 0x16;
str3 = str3 + current.Text + "|";
Label_0169:
num23 = 0x18;
}
if (enumerator is IDisposable)
{
(enumerator as IDisposable).Dispose();
}
Label_019C:
num23 = 0x19;
str3 = Strings.Left(str3, Strings.Len(str3) - 1);
goto Label_02A4;
Label_01B7:
num23 = 0x1b;
if (str5 != "String()")
{
goto Label_028B;
}
Label_01D5:
num23 = 0x1c;
int num17 = Information.UBound((Array) KNamev, 1);
int num = Information.LBound((Array) KNamev, 1);
goto Label_0269;
Label_01F6:
num23 = 0x1d;
if (!Operators.ConditionalCompareObjectNotEqual(NewLateBinding.LateIndexGet(KNamev, new object[] { num }, null), "", false))
{
goto Label_0260;
}
Label_0227:
num23 = 30;
str3 = Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(str3, NewLateBinding.LateIndexGet(KNamev, new object[] { num }, null)), "|"));
Label_0260:
num23 = 0x20;
num++;
Label_0269:
if (num <= num17)
{
goto Label_01F6;
}
Label_0272:
num23 = 0x21;
str3 = Strings.Left(str3, Strings.Len(str3) - 1);
goto Label_02A4;
Label_028B:
num23 = 0x24;
Interaction.MsgBox(str4 + " is an unsupported type to be passed to KeyGen", MsgBoxStyle.OkOnly, null);
Label_02A4:
num23 = 0x26;
int num6 = Strings.Len(str3);
Label_02B1:
num23 = 0x27;
int num9 = Strings.Len(KPass);
Label_02BD:
num23 = 40;
numArray3[1] = 0x2e;
Label_02C7:
num23 = 0x29;
numArray3[2] = 0x59;
Label_02D1:
num23 = 0x2a;
numArray3[3] = 0x8e;
Label_02DE:
num23 = 0x2b;
numArray3[4] = 0x3f;
Label_02E8:
num23 = 0x2c;
numArray3[5] = 0xe7;
Label_02F5:
num23 = 0x2d;
numArray3[6] = 0x20;
Label_02FF:
num23 = 0x2e;
numArray3[7] = 0x81;
Label_030C:
num23 = 0x2f;
numArray3[8] = 0x33;
Label_0316:
num23 = 0x30;
numArray3[9] = 0x1c;
Label_0321:
num23 = 0x31;
numArray3[10] = 0x61;
Label_032C:
num23 = 50;
numArray3[11] = 0xf8;
Label_033A:
num23 = 0x33;
numArray3[12] = 0x29;
Label_0345:
num23 = 0x34;
numArray3[13] = 0x88;
Label_0353:
num23 = 0x35;
numArray3[14] = 0x35;
Label_035E:
num23 = 0x36;
numArray3[15] = 0x4e;
Label_0369:
num23 = 0x37;
numArray3[0x10] = 0xa4;
Label_0377:
num23 = 0x38;
int index = 0;
Label_037E:
num23 = 0x39;
int num5 = 0;
Label_0385:
num23 = 0x3a;
numArray5[num5] = num5;
Label_0390:
num23 = 0x3b;
num5++;
int num24 = 0x200;
if (num5 <= num24)
{
goto Label_0385;
}
Label_03A8:
num23 = 60;
num5 = 0;
Label_03AF:
num23 = 0x3d;
index = ((0 + index) + num5) % 0x100;
Label_03C2:
num23 = 0x3e;
int num15 = numArray5[num5];
Label_03CD:
num23 = 0x3f;
numArray5[num5] = numArray5[index];
Label_03DB:
num23 = 0x40;
numArray5[index] = num15;
Label_03E6:
num23 = 0x41;
num5++;
num24 = 0x200;
if (num5 <= num24)
{
goto Label_03AF;
}
Label_03FE:
num23 = 0x42;
if (KType != 1)
{
goto Label_0483;
}
Label_040C:
num23 = 0x43;
int num8 = 0;
Label_0413:
num23 = 0x44;
int num3 = 0x10;
Label_041B:
num23 = 0x45;
string sDest = Strings.StrDup(0x10, " ");
Label_042D:
num23 = 70;
num5 = 0;
Label_0434:
num23 = 0x47;
numArray[numArray5[num5]] = 0x30 + num8;
Label_0445:
num23 = 0x48;
num8++;
Label_044F:
num23 = 0x49;
if (num8 != 10)
{
goto Label_0466;
}
Label_045F:
num23 = 0x4a;
num8 = 0;
Label_0466:
num23 = 0x4c;
num5++;
num24 = 0x200;
if (num5 <= num24)
{
goto Label_0434;
}
goto Label_0582;
Label_0483:
num23 = 0x4e;
if (KType != 2)
{
goto Label_0563;
}
Label_0494:
num23 = 0x4f;
num8 = 0;
Label_049B:
num23 = 80;
int num2 = 0;
Label_04A1:
num23 = 0x51;
num3 = 0x10;
Label_04A9:
num23 = 0x52;
sDest = Strings.StrDup(0x10, " ");
Label_04BB:
num23 = 0x53;
bool flag = false;
Label_04C1:
num23 = 0x54;
num5 = 0;
Label_04C8:
num23 = 0x55;
if (!flag)
{
goto Label_050D;
}
Label_04D3:
num23 = 0x56;
numArray[numArray5[num5]] = 0x30 + num8;
Label_04E4:
num23 = 0x57;
num8++;
Label_04EE:
num23 = 0x58;
if (num8 != 10)
{
goto Label_0505;
}
Label_04FE:
num23 = 0x59;
num8 = 0;
Label_0505:
num23 = 0x5b;
flag = false;
goto Label_0546;
Label_050D:
num23 = 0x5d;
Label_0512:
num23 = 0x5e;
numArray[numArray5[num5]] = 0x41 + num2;
Label_0522:
num23 = 0x5f;
num2++;
Label_052A:
num23 = 0x60;
if (num2 != 0x1a)
{
goto Label_053F;
}
Label_0539:
num23 = 0x61;
num2 = 0;
Label_053F:
num23 = 0x63;
flag = true;
Label_0546:
num23 = 0x65;
num5++;
num24 = 0x200;
if (num5 <= num24)
{
goto Label_04C8;
}
goto Label_0582;
Label_0563:
num23 = 0x67;
Label_0568:
num23 = 0x68;
num3 = 8;
Label_056F:
num23 = 0x69;
sDest = Strings.StrDup(0x13, " ");
Label_0582:
num23 = 0x6b;
int num4 = 1;
Label_0589:
num23 = 0x6c;
int num18 = num6;
num5 = 1;
goto Label_05F1;
Label_0596:
num23 = 0x6d;
numArray2[num4] = (numArray2[num4] + Strings.Asc(Strings.Mid(str3, num5, 1))) ^ 0x12;
Label_05B7:
num23 = 110;
num7 += numArray2[num4];
Label_05C5:
num23 = 0x6f;
num4++;
Label_05CF:
num23 = 0x70;
if (num4 != 9)
{
goto Label_05E6;
}
Label_05DF:
num23 = 0x71;
num4 = 1;
Label_05E6:
num23 = 0x73;
num5++;
Label_05F1:
if (num5 <= num18)
{
goto Label_0596;
}
Label_05FB:
num23 = 0x74;
int num19 = num9;
num5 = 1;
goto Label_0662;
Label_0608:
num23 = 0x75;
numArray4[num4] = (numArray4[num4] + Strings.Asc(Strings.Mid(KPass, num5, 1))) ^ 0x19;
Label_0628:
num23 = 0x76;
num10 += numArray4[num4];
Label_0636:
num23 = 0x77;
num4++;
Label_0640:
num23 = 120;
if (num4 != 9)
{
goto Label_0657;
}
Label_0650:
num23 = 0x79;
num4 = 1;
Label_0657:
num23 = 0x7b;
num5++;
Label_0662:
if (num5 <= num19)
{
goto Label_0608;
}
Label_066C:
num23 = 0x7c;
int num16 = (num7 + num10) % 0x200;
Label_067D:
num23 = 0x7d;
num4 = 1;
Label_0684:
num23 = 0x7e;
int num14 = 1;
Label_068B:
num23 = 0x7f;
int num20 = num3;
num5 = 1;
goto Label_07F2;
Label_069B:
num23 = 0x80;
numArray4[num5] ^= numArray3[num5];
Label_06B2:
num23 = 0x81;
int number = Math.Abs((int) (((numArray2[num5] ^ numArray4[num5]) % 0x200) - num16));
Label_06D4:
num23 = 130;
if (KType != 3)
{
goto Label_07BA;
}
Label_06E8:
num23 = 0x83;
if (number >= 0x10)
{
goto Label_0720;
}
Label_06FB:
num23 = 0x84;
StringType.MidStmtStr(ref sDest, num4, 2, "0" + Conversion.Hex(number));
goto Label_0742;
Label_0720:
num23 = 0x86;
Label_0728:
num23 = 0x87;
StringType.MidStmtStr(ref sDest, num4, 2, Conversion.Hex(number));
Label_0742:
num23 = 0x89;
if (!((num14 == 2) & (num4 < 0x12)))
{
goto Label_0782;
}
Label_075B:
num23 = 0x8a;
num4++;
Label_0768:
num23 = 0x8b;
StringType.MidStmtStr(ref sDest, num4 + 1, 1, "-");
Label_0782:
num23 = 0x8d;
num4 += 2;
Label_078F:
num23 = 0x8e;
num14++;
Label_079C:
num23 = 0x8f;
if (num14 != 3)
{
goto Label_07E4;
}
Label_07AE:
num23 = 0x90;
num14 = 1;
goto Label_07E4;
Label_07BA:
num23 = 0x93;
Label_07C2:
num23 = 0x94;
StringType.MidStmtStr(ref sDest, num5, 1, Conversions.ToString(Strings.Chr(numArray[number])));
Label_07E4:
num23 = 150;
num5++;
Label_07F2:
if (num5 <= num20)
{
goto Label_069B;
}
Label_07FF:
num23 = 0x97;
str = sDest;
goto Label_0AD0;
Label_0813:
num22 = 0;
switch ((num22 + 1))
{
case 1:
goto Label_0001;
case 2:
goto Label_000A;
case 3:
goto Label_0019;
case 4:
goto Label_0025;
case 5:
goto Label_0034;
case 6:
goto Label_0040;
case 7:
goto Label_004C;
case 8:
goto Label_0056;
case 9:
goto Label_0066;
case 10:
goto Label_007C;
case 11:
case 0x25:
case 15:
case 0x12:
case 0x1a:
case 0x22:
case 0x26:
goto Label_02A4;
case 12:
case 13:
goto Label_0085;
case 14:
goto Label_00A0;
case 0x10:
goto Label_00B1;
case 0x11:
goto Label_00CC;
case 0x13:
goto Label_00F1;
case 20:
goto Label_010F;
case 0x15:
goto Label_012F;
case 0x16:
goto Label_0150;
case 0x17:
case 0x18:
goto Label_0169;
case 0x19:
goto Label_019C;
case 0x1b:
goto Label_01B7;
case 0x1c:
goto Label_01D5;
case 0x1d:
goto Label_01F6;
case 30:
goto Label_0227;
case 0x1f:
case 0x20:
goto Label_0260;
case 0x21:
goto Label_0272;
case 0x23:
case 0x24:
goto Label_028B;
case 0x27:
goto Label_02B1;
case 40:
goto Label_02BD;
case 0x29:
goto Label_02C7;
case 0x2a:
goto Label_02D1;
case 0x2b:
goto Label_02DE;
case 0x2c:
goto Label_02E8;
case 0x2d:
goto Label_02F5;
case 0x2e:
goto Label_02FF;
case 0x2f:
goto Label_030C;
case 0x30:
goto Label_0316;
case 0x31:
goto Label_0321;
case 50:
goto Label_032C;
case 0x33:
goto Label_033A;
case 0x34:
goto Label_0345;
case 0x35:
goto Label_0353;
case 0x36:
goto Label_035E;
case 0x37:
goto Label_0369;
case 0x38:
goto Label_0377;
case 0x39:
goto Label_037E;
case 0x3a:
goto Label_0385;
case 0x3b:
goto Label_0390;
case 60:
goto Label_03A8;
case 0x3d:
goto Label_03AF;
case 0x3e:
goto Label_03C2;
case 0x3f:
goto Label_03CD;
case 0x40:
goto Label_03DB;
case 0x41:
goto Label_03E6;
case 0x42:
goto Label_03FE;
case 0x43:
goto Label_040C;
case 0x44:
goto Label_0413;
case 0x45:
goto Label_041B;
case 70:
goto Label_042D;
case 0x47:
goto Label_0434;
case 0x48:
goto Label_0445;
case 0x49:
goto Label_044F;
case 0x4a:
goto Label_045F;
case 0x4b:
case 0x4c:
goto Label_0466;
case 0x4d:
case 0x66:
case 0x6a:
case 0x6b:
goto Label_0582;
case 0x4e:
goto Label_0483;
case 0x4f:
goto Label_0494;
case 80:
goto Label_049B;
case 0x51:
goto Label_04A1;
case 0x52:
goto Label_04A9;
case 0x53:
goto Label_04BB;
case 0x54:
goto Label_04C1;
case 0x55:
goto Label_04C8;
case 0x56:
goto Label_04D3;
case 0x57:
goto Label_04E4;
case 0x58:
goto Label_04EE;
case 0x59:
goto Label_04FE;
case 90:
case 0x5b:
goto Label_0505;
case 0x5c:
case 100:
case 0x65:
goto Label_0546;
case 0x5d:
goto Label_050D;
case 0x5e:
goto Label_0512;
case 0x5f:
goto Label_0522;
case 0x60:
goto Label_052A;
case 0x61:
goto Label_0539;
case 0x62:
case 0x63:
goto Label_053F;
case 0x67:
goto Label_0563;
case 0x68:
goto Label_0568;
case 0x69:
goto Label_056F;
case 0x6c:
goto Label_0589;
case 0x6d:
goto Label_0596;
case 110:
goto Label_05B7;
case 0x6f:
goto Label_05C5;
case 0x70:
goto Label_05CF;
case 0x71:
goto Label_05DF;
case 0x72:
case 0x73:
goto Label_05E6;
case 0x74:
goto Label_05FB;
case 0x75:
goto Label_0608;
case 0x76:
goto Label_0628;
case 0x77:
goto Label_0636;
case 120:
goto Label_0640;
case 0x79:
goto Label_0650;
case 0x7a:
case 0x7b:
goto Label_0657;
case 0x7c:
goto Label_066C;
case 0x7d:
goto Label_067D;
case 0x7e:
goto Label_0684;
case 0x7f:
goto Label_068B;
case 0x80:
goto Label_069B;
case 0x81:
goto Label_06B2;
case 130:
goto Label_06D4;
case 0x83:
goto Label_06E8;
case 0x84:
goto Label_06FB;
case 0x85:
case 0x88:
case 0x89:
goto Label_0742;
case 0x86:
goto Label_0720;
case 0x87:
goto Label_0728;
case 0x8a:
goto Label_075B;
case 0x8b:
goto Label_0768;
case 140:
case 0x8d:
goto Label_0782;
case 0x8e:
goto Label_078F;
case 0x8f:
goto Label_079C;
case 0x90:
goto Label_07AE;
case 0x91:
case 0x92:
case 0x95:
case 150:
goto Label_07E4;
case 0x93:
goto Label_07BA;
case 0x94:
goto Label_07C2;
case 0x97:
goto Label_07FF;
case 0x98:
goto Label_0AD0;
default:
goto Label_0AC5;
}
Label_0A85:
num22 = num23;
switch (((num21 > -2) ? num21 : 1))
{
case 0:
goto Label_0AC5;
case 1:
goto Label_0813;
}
}
catch
{
ProjectData.SetProjectError((Exception) obj1);
goto Label_0A85;
}
Label_0AC5:
throw ProjectData.CreateProjectError(-2146828237);
Label_0AD0:
if (num22 != 0)
{
ProjectData.ClearProjectError();
}
return str;
}
public static string GetHardDiskSerialNumber()
{
ManagementObject current;
string str2 = string.Empty;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * From Win32_NetworkAdapter");
ManagementObjectCollection objects = searcher.Get();
using (ManagementObjectCollection.ManagementObjectEnumerator enumerator = objects.GetEnumerator())
{
while (enumerator.MoveNext())
{
current = (ManagementObject) enumerator.Current;
if (Strings.Len(RuntimeHelpers.GetObjectValue(current["MACAddress"])) > 7)
{
str2 = Conversions.ToString(current["MACAddress"]);
goto Label_008F;
}
}
}
Label_008F:
searcher.Dispose();
searcher = null;
current.Dispose();
current = null;
return str2;
}
private static void MakeDecTab()
{
int num3;
int index = 0;
do
{
aDecTab[index] = -1;
index++;
num3 = 0xff;
}
while (index <= num3);
int num2 = 0;
index = 0x41;
do
{
aDecTab[index] = num2;
num2++;
index++;
num3 = 90;
}
while (index <= num3);
index = 0x61;
do
{
aDecTab[index] = num2;
num2++;
index++;
num3 = 0x7a;
}
while (index <= num3);
index = 0x30;
do
{
aDecTab[index] = num2;
num2++;
index++;
num3 = 0x39;
}
while (index <= num3);
index = 0x2b;
aDecTab[index] = num2;
num2++;
index = 0x2f;
aDecTab[index] = num2;
num2++;
index = 0x3d;
aDecTab[index] = num2;
}
private static byte SHL(byte bytValue, int intShift)
{
if ((intShift > 0) & (intShift < 8))
{
return (byte) Math.Round((double) ((bytValue * Math.Pow(2.0, (double) intShift)) % 256.0));
}
if (intShift == 0)
{
return bytValue;
}
return 0;
}
private static byte SHR(byte bytValue, int intShift)
{
if ((intShift > 0) & (intShift < 8))
{
return (byte) (((ulong) bytValue) / ((long) Math.Round(Math.Pow(2.0, (double) intShift))));
}
if (intShift == 0)
{
return bytValue;
}
return 0;
}
}
}
For registration (Code)
private void BtnAddNew_Click(object sender, EventArgs e)
{
try
{
if (MdlKeyEncrypt.GenerateSoftwareKEY(this.TxtUser.Text.Trim(), this.TxtID.Text.Trim(), 2) == this.TxtKey.Text.Trim())
{
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "UserName", MdlKeyEncrypt.EncodeStr64(this.TxtUser.Text.Trim()));
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "HardwareID", MdlKeyEncrypt.EncodeStr64(this.TxtID.Text.Trim()));
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "Key", MdlKeyEncrypt.EncodeStr64(this.TxtKey.Text.Trim()));
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "KeyType", MdlKeyEncrypt.EncodeStr64("Alphanumeric"));
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\" + MdlFunctions.ApplicationName, "RegSet", MdlKeyEncrypt.EncodeStr64("REGISTERED"));
Interaction.MsgBox("SOFTWARE REGISTERED SUCCESSFULLY!", MsgBoxStyle.Information, "BUILD TECH");
this.Close();
}
else
{
Interaction.MsgBox("WRONG KEY", MsgBoxStyle.Information, null);
this.TxtKey.Focus();
}
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
Exception exception = exception1;
Interaction.MsgBox(exception.Message, MsgBoxStyle.OkOnly, null);
ProjectData.ClearProjectError();
}