日期:2014-05-18 浏览次数:20600 次
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace TopWin.Common.EncryptFunction
{
public class Key
{
[DllImport("kernel32.dll")]
private static extern int GetVolumeInformation
(
string lpRootPathName,
string lpVolumeNameBuffer,
int nVolumeNameSize,
ref int lpVolumeSerialNumber,
int lpMaximumComponentLength,
int lpFileSystemFlags,
string lpFileSystemNameBuffer,
int nFileSystemNameSize
);
/// <summary>
/// C盘序列号
/// </summary>
/// <param name=""></param>
/// <returns></returns>
public static string HDVal()
{
const int MAX_FILENAME_LEN = 256;
int retVal = 0;
int a = 0;
int b = 0;
string str1 = null;
string str2 = null;
int i = GetVolumeInformation(
"c:\\",
str1,
MAX_FILENAME_LEN,
ref retVal,
a,
b,
str2,
MAX_FILENAME_LEN
);
return retVal.ToString();
}
}
}
------解决方案--------------------
public class Hash
{
#region 加密
/// <summary>
/// MD5加密
/// </summary>
/// <param name="InputString">要加密的字串</param>
/// <returns>密文</returns>
public static string Md5hash_String(string InputString)
{
InputString = Md5hash_String(InputString, "MD5");
return InputString;
}
/// <summary>
/// SHA1,MD5加密
/// </summary>
/// <param name="s">要加密的字符串</param>
/// <param name="format">加密格式 MD5 或 SHA1</param>
/// <returns>返回加密后的字串</returns>
public static string Md5hash_String(string InputString, string format)
{
if (format == "SHA1")
{
InputString = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(InputString, "SHA1");
}
else if (format == "MD5")
{
InputString = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(InputString, "MD5");
}
return InputString;
}
#endregion
------解决方案--------------------
学习
------解决方案--------------------
我有个想法 不知道行不行的通
楼住的意思是想让一个序列号只可以让一个客户来登陆使用 不可能很多人都用这一个号?(理解正确的话)
可以针对序列号建一个表2个字段一个序列号一个是客户登陆IP, 当用户用此序列号登陆时 在对应的序列号中写入IP值
离开时则清空IP ,这样当一个序列号被使用时 其他人在用就判断IP不为空 就禁制登陆
------解决方案--------------------
winner2050~~~真下本
------解决方案--------------------