mysql数据库的认证密码有两种方式,mysql
41版本之前是mysql323加密,mysql
41和之后的版本都是mysqlsha1加密,mysql数据库中自带old_password(str)和password(str)函数,它们均可以在mysql数据库里进行查询,前者是mysql323加密,后者是mysqlsha1方式加密。
(1)以mysql323方式加密
selectold_password('111111');
(2)以mysqlsha1方式加密
select
password('111111');
mysql323加密中生成的是16位字符串,而在mysqlsha1中生存的是41位字符串,其中是不加入实际的密码运算中,通过观察在很多用户中都携带了"",在实际破解过程中去掉"",也就是说mysqlsha1加密的密码的实际位数是40位。
#region DES加密字符串
/// <summary>
/// 加密字符串
/// 注意:密钥必须为8位
/// </summary>
/// <param name="strText">字符串</param>
public string DesEncrypt(string strText)
{
byte[] byKey = null;
byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
try
{
string encryptKey = "XX_XX_XX"; //密钥
byKey = SystemTextEncodingUTF8GetBytes(encryptKey);
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = EncodingUTF8GetBytes(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, desCreateEncryptor(byKey, IV), CryptoStreamModeWrite);
csWrite(inputByteArray, 0, inputByteArrayLength);
csFlushFinalBlock();
return ConvertToBase64String(msToArray());
}
catch
{
}
return strText;
}
#endregion
#region DES解密字符串
/// <summary>
/// 解密字符串
/// </summary>
/// <param name="inputString">加了密的字符串</param>
public string DesDecrypt(string inputString)
{
byte[] byKey = null;
byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
byte[] inputByteArray = new Byte[inputStringLength];
try
{
string decryptKey = "XX_XX_XX";
byKey = SystemTextEncodingUTF8GetBytes(decryptKeySubstring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = ConvertFromBase64String(inputString);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, desCreateDecryptor(byKey, IV), CryptoStreamModeWrite);
csWrite(inputByteArray, 0, inputByteArrayLength);
csFlushFinalBlock();
SystemTextEncoding encoding = new SystemTextUTF8Encoding();
return encodingGetString(msToArray());
}
catch
{
}
return inputString;
}
#endregion
===这个是DES方式加密解密字符串的
SystemSecurityCryptographyMD5CryptoServiceProvider md5=new SystemSecurityCryptographyMD5CryptoServiceProvider();
return ConvertToBase64String(md5ComputeHash(SystemTextEncodingUnicodeGetBytes(yourstring)));
===这个是MD5的
实现代码也给你写好了,希望能对你有帮助
第一种:Mdbpath = AppPath & "\qhdedumdb" '改成你的数据库名称
Mdpass = "123456" '改成你的数据库密码Connstring = "Provider=MicrosoftJetOLEDB40;Data Source=" & Mdbpath & ";Persist Security Info=False;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:database password='" & Mdpass & "'" '设置连接字符串
Adodc1ConnectionString = Connstring
'设置数据记录源
Adodc1RecordSource = "select from 你的表名"Adodc1Refresh 第二种:Mdbpath = AppPath & "\qhdedumdb" '改成你的数据库名称
Mdpass = "123456" '改成你的数据库密码'连接数据库 并初始化CONN,将用于ADODB连接方式
Connstr = "DBQ=" + Mdbpath + ";DRIVER={Microsoft Access Driver (mdb)};password='" & Mdpass & "'"
Set Conn = CreateObject("ADODBCONNECTION")
ConnOpen Connstr
'创建一个记录集对象
Set Rs = CreateObject("adodbrecordset")
SQL = "select from 你的表名 "
RsOpen SQL, Conn, 1, 1text1=rs("字段名")
以上就是关于数据库加密有几种全部的内容,包括:数据库加密有几种、MSSQL数据库连接密码加密、vb连接access加密数据库 要怎么设置等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)