public class Filesini
{
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string sectionName, string key, string defaultValue, byte[] returnBuffer, int size, string filePath);
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string sectionName, string key, string value, string filePath);
public bool ExistINIFile(string strinipath)
{
return File.Exists(strinipath);
}
public bool isSameSectionName(string strinipath,string name)
{
List<string> listName = GetSectionNames(strinipath);
if (ExistINIFile(strinipath))
{
foreach (string n in listName)
{
if (n == name) {
return true;
}
}
}
return false;
}
#region 加密
#region ini文件DES加密/解密使用中
// 初始化DES加密的密钥和一个随机的、8比特的初始化向量(IV)
private byte[] key_8 = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
private byte[] IV_8 = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef };
public string DES_Encrypt(string encryptString)
{
try
{
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
DESCryptoServiceProvider dCSP = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoS
C#编程-ini文件读写MD5Encrypt加密、DES加密
最新推荐文章于 2026-06-03 20:17:16 发布
本文介绍了一个使用C#实现的INI文件读写及加密解密的类,包括了基本的文件存在检查、节名比较、以及利用DES和MD5进行数据加密的功能。此外,还提供了读写INI文件的具体方法,适用于需要安全存储配置信息的应用场景。


1148

被折叠的 条评论
为什么被折叠?



