Windows应用程序在Visual Studio 2005中使用c#实现串行密钥实现 [英] Serial Key Implementation in Windows application using c# in Visual Studio 2005

查看:84
本文介绍了Windows应用程序在Visual Studio 2005中使用c#实现串行密钥实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在部署Visual Studio 2005的过程中在Windows应用程序中生成并给出序列号并对其进行验证:(

How to generate and give serial number and validate it in windows application during deployment Visual Studio 2005 :(

推荐答案

这是一个简单的加密和解密.非常基本.
您要做的是显示HDD或CPU序列号.
然后,如果对其进行加密并将其发送回您的客户端,则他/她然后在其中添加加密的代码,然后您的应用程序解密该代码并与HDD或CPU代码进行匹配,如果匹配则用户可以登录.

Here is a simple Encrypt and Decrypt. Very basic.
What you do is display the HDD or CPU serial code.
Then if encrypt it and send it back to your client, he/she then adds the encrypted code in and then your app decrypts the code and matches against the HDD or CPU code and if Matches they user can login.

public class Security
    {
        private const string Key = "31428571428571428571428571428571";

        public static string SimpleEncrypt(string toEncrypt)
        {
            int len = toEncrypt.Length;
            const int keyMin = 0;
            int keyMax = Key.Length;
            int count = 0;
            List<char> encryptedCodes = new List<char>();

            for (int i = 0; i < len; i++)
            {
                if (count == keyMax)
                {
                    count = keyMin;
                }
                int asciiDec = ((int)(toEncrypt[i])) + Convert.ToInt32(Key[count]);
                encryptedCodes.Add((char)asciiDec);
            }
            return new string(encryptedCodes.ToArray());
        }
        public static string SimpleDecrypt(string toDecrypt)
        {
            int len = toDecrypt.Length;
            const int keyMin = 0;
            int keyMax = Key.Length;
            int count = 0;
            List<char> encryptedCodes = new List<char>();

            for (int i = 0; i < len; i++)
            {
                if (count == keyMax)
                {
                    count = keyMin;
                }
                int asciiDec = ((int)(toDecrypt[i])) - Convert.ToInt32(Key[count]);
                encryptedCodes.Add((char)asciiDec);
            }
            return new string(encryptedCodes.ToArray());
        }
    }



如果有帮助,请投票.



Please vote if this helps.


Google我的应用程序中的C#序列号".
Google "C# serial number in my application".


这篇关于Windows应用程序在Visual Studio 2005中使用c#实现串行密钥实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆