zoukankan      html  css  js  c++  java
  • SQLDBCompare2.4 序列号代码

     private void button1_Click(object sender, EventArgs e)
            
    {
                textBox1.Text 
    = GenerateNewKey("$BE$T$"102false500);
            }

            
    public static string GenerateNewKey(string strSecurityCode, int nProductCode, bool bTrial, int nTrialDays)
            
    {
                
    if (!strSecurityCode.Equals("$BE$T$"))
                
    {
                    
    return "";
                }

                
    string str = Guid.NewGuid().ToString().Replace("-""");
                
    string str2 = "";
                
    if (bTrial)
                
    {
                    str2 
    = "2" + nTrialDays.ToString("D3"+ "00000000" + nProductCode.ToString("D3");
                }

                
    else
                
    {
                    str2 
    = "1123ABCDEFGH" + nProductCode.ToString("D3");
                }

                
    char[] chArray = (str + "$" + str2).ToCharArray();
                
    byte[] inArray = new byte[chArray.Length];
                
    for (int i = 0; i < chArray.Length; i++)
                
    {
                    inArray[i] 
    = (byte)chArray[i];
                }

                
    string strKey = Convert.ToBase64String(inArray);
                
    string str4 = GetStringCheckSumValue(strKey).ToString("D3");
                
    return (strKey + str4);
            }


     

            
    public static int GetStringCheckSumValue(string strKey)
            
    {
                
    int i1 = 0;
                
    byte b2 = 1;
                
    for (int i2 = 0; i2 < strKey.Length; i2++)
                
    {
                    
    byte b1 = (byte)strKey[i2];
                    
    for (int i3 = 0; i3 < 8; i3++)
                    
    {
                        
    if ((b1 & (b2 << (i3 & 31))) == 0)
                            i1
    ++;
                    }

                }

                
    return i1;
            }


  • 相关阅读:
    C. Uncle Bogdan and Country Happiness solution
    B
    A
    Problem of Precision solution
    hdu-2255 D
    hdu1325 Is It A Tree? solution
    一体化办公系统
    dx:ASPxGridView 批量删除
    linq 多表查询出现‘查询包含对不同数据上下文上所定义项的引用。’
    DevExpress学习笔记之ASPxMenu
  • 原文地址:https://www.cnblogs.com/lovebanyi/p/927869.html
Copyright © 2011-2022 走看看