Click here to Skip to main content
11,582,584 members (72,041 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 WinForm
hi to all,

how to generate the license key based on the MAC address of the Computer.

i have used the following code:
public string RandomString()
       {
 
           string input = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
           StringBuilder builder = new StringBuilder();
           char ch;
           for (int i = 0; i < 5; i++)
           {
               ch = input[rd.Next(0, input.Length)];
               builder.Append(ch);
           }
           return builder.ToString();
 
       }
private void btn_License_Click(object sender, EventArgs e)
        {
 
            string s1 = RandomString();
            string s2 = RandomString();
            string s3 = RandomString();
            string s4 = RandomString();
            string s5 = RandomString();
            textBox1.Text = s1 + " - " + s2 + " - " + s3 + " - " + s4 + " - " + s5;
}
Posted 9-Jul-13 20:06pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

That does nothing at all related to MAC addresses - it you want to use them, you will first have to retrieve it. This will help: Retrieving IP and MAC addresses for a LAN[^] - there is a method there to retrive the current PC MAC address.

But - don't waste too much time on this: MAC addresses can be spoofed, a PC will only have a MAC address if it has an active network connector, and most software protection methods annoy legitimate users more than they inconvenience pirates. You have to decide what level of piracy you are likely to get, how many of those can be converted into sales by protecting the software and the cost of the time to implement protection. Very often, it just isn't worth the effort...
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 335
1 Sergey Alexandrovich Kryukov 220
2 Andy Lanng 124
3 virusstorm 109
4 Kornfeld Eliyahu Peter 90
0 OriginalGriff 1,358
1 Sergey Alexandrovich Kryukov 970
2 Abhinav S 671
3 F-ES Sitecore 505
4 Suvendu Shekhar Giri 448


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 10 Jul 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100