软件做好了,老板说要搞注册码,谢谢大家帮忙

解决方案 »

  1.   

    你可以写一段代码去读机器的硬件号码,比方说硬盘号,网卡的MAC地址,等等.
    当然,一旦都是读硬盘号的,具体的代码你用GOOGLE搜索一下就会有的.
    然后将这个硬盘号用HASH算法,或者其它算法加密即可~~~
    然后自己做一个算好器,把加密解密的弄好就OK了,
    方法就是这样,具体东西还是要你去做得.
      

  2.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Web.Configuration;
    using Hasher;
    /// <summary>
    /// cs 的摘要说明
    /// </summary>
    /// 
    namespace cs
    {
        public class cs
        {
        //判断序列号 
            public bool  css()
            //m为配置文件值
            //x为序列号值
            //css进行比较该注册码是否正确
            {
                Hasher.Hasher hash = new Hasher.Hasher();
                string xulie = hash.Sern();
                string m = ConfigurationManager.AppSettings.Get("message").ToString();
               
                    if (m == xulie)
                {
                    return true;            }
                else
                {
                    return false;            }
         
            }
          
            public bool text(string x)
            //x为写入的参数
            //用于注册码不正确的时候使用
            {
                Hasher.Hasher hash = new Hasher.Hasher();
                string xulie = hash.Sern();
                if (x == xulie)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
      
            public void   con(string path, string x)
            //写入配置文件信息
            //path是请求的虚拟路径
            //x要修改的值
            {
              
                    Configuration config = WebConfigurationManager.OpenWebConfiguration(path);                config.AppSettings.Settings.Clear();
                    //   string m = ConfigurationManager.AppSettings.Get("message");
                    config.AppSettings.Settings.Add("message", x);
                    config.Save();        }
               }
    }
      

  3.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Security.Cryptography;
    using System.Management;
    /// <summary>
    /// Hasher 的摘要说明
    /// </summary>
    /// 
    namespace Hasher
    {public class Hasher
    {

            // private byte[] _HashKey;   //哈希密钥存储变量
            public  string _HashText;  //待加密的字符串
      //      public Hasher()
       //     {
        //    }
            // 需要产生加密哈希的字符串
            public string HashText
            {
                set
                {
                    _HashText = value;
                }
                get
                {
                    return _HashText;
                }
            }        /// 使用MD5CryptoServiceProvider类产生哈希值。不需要提供密钥。
            /// </summary>
            /// <returns></returns>
            public string MD5Hasher()
            {
                byte[] MD5Data = System.Text.Encoding.UTF8.GetBytes(HashText);            MD5 Md5 = new MD5CryptoServiceProvider();            byte[] Result = Md5.ComputeHash(MD5Data);            return Convert.ToBase64String(Result); //返回长度为25字节字符串
            }
        //获取cpu序列号
        public String GetCpuID()
            {
                ManagementClass mc = new ManagementClass("Win32_Processor");
                ManagementObjectCollection moc = mc.GetInstances();            String strCpuID = null;
                foreach (ManagementObject mo in moc)
                {
                    strCpuID = mo.Properties["ProcessorId"].Value.ToString();
                    break;
                }
                return strCpuID;
            }//end method
            //获取硬盘序列号
            public  String GetDriveID()
            {
                string driveSerialNum = "";
                Scripting.FileSystemObjectClass MySystem = new Scripting.FileSystemObjectClass();
                foreach (Scripting.Drive MyDriver in MySystem.Drives)
                {
                    string SerialNumber = "";
                   try
                   {
                        SerialNumber = MyDriver.SerialNumber.ToString();
                        driveSerialNum = driveSerialNum + SerialNumber;
                   }
                   catch (Exception ex)
                   {
                        
                   }            }            return driveSerialNum;
            }    public String strJia()
            {
                string strJiami = "";
                strJiami = GetCpuID() + GetDriveID();            return strJiami;
            }
        public string jiqixuelie;
            public string duijiqima = null;
            ///得到机器码
        public string hashGetDriveID()
       
        {
            Hasher hs = new Hasher();        hs.HashText = hs.strJia();
            string jiqi = hs.MD5Hasher();
            duijiqima = jiqi.Substring(8, 5);
            return duijiqima;
        }
        
            public string Sern()
            //最终的序列号   //m为配置文件值
            //x为序列号值
            //css进行比较该注册码是否正确
            {
                            //888888888888888888888888888888888获取机器码
                Hasher hs = new Hasher();            //88888888888888888888888888888888888888888888888888获取序列号
                Hasher hash = new Hasher();
                hash.HashText = hs.hashGetDriveID().ToString ();
                jiqixuelie = hash.MD5Hasher();
                return jiqixuelie;
            }

    }
    }
      

  4.   

    <appSettings>
      <clear />
      <add key="message" value="gSHtZ6yh/QegTbH8/iTaIg==" />
     </appSettings>
    上面这些注册码是在配置文件里写的
      

  5.   

    wuda8(c# asp.net 2.0博客)大哥,我做的winform啊,这个我不能用吧
      

  6.   

    using Microsoft.Win32;然后研究一下注册表RegKey类etc
      

  7.   

    C#winfrom程序怎么做注册码? 求帮助
      

  8.   

    using Microsoft.Win32; //對注冊表操作引用這個命名空間//Registry类、RegistryKey类
    手頭上也沒有例子
      

  9.   

    现在的人真够懒的。思路都有了,还不动手,googel那么方便,唉