国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

C#程序怎么做注冊碼?

2024-07-21 02:26:05
字體:
來源:轉載
供稿:網友
  • 本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。
  • 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();

    }


    }
    }
     
     
    top
     
      回復人:wuda8(c# asp.net 2.0博客) ( ) 信譽:93 2006-11-1 15:37:43 得分:0
     
     
    ?
    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;
    }

    }
     
     

    發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 尖扎县| 双城市| 沾益县| 长岭县| 花垣县| 策勒县| 湖北省| 永修县| 东乡族自治县| 满洲里市| 新郑市| 黎川县| 香港| 沂南县| 阿巴嘎旗| 舒兰市| 深州市| 西吉县| 潜江市| 芦山县| 山阳县| 方正县| 青神县| 江都市| 察隅县| 平湖市| 灌阳县| 大连市| 堆龙德庆县| 大英县| 佛山市| 潮安县| 保德县| 建水县| 安陆市| 武夷山市| 丹东市| 定兴县| 龙泉市| 静乐县| 浦东新区|