對稱加密解密

2022-05-15 02:48:20 字數 1476 閱讀 6982

/// /// 幫助類

///

public class cryptohelper

;encryptor = _provider.createencryptor();

decryptor = _provider.createdecryptor();

}/// /// initializes a new instance of the class.

///

/// /// 金鑰

///

public cryptohelper(string key) : this("tripledes", key)

/// /// 加密演算法

///

/// /// the clear text.

///

/// /// 密文

///

public string encrypt(string cleartext)

while (_bytesread > 0);

_cryptostream.flushfinalblock();

//// 獲取加密後的文字

_buffer = _encryptedstream.toarray();

string _encryptedtext = convert.tobase64string(_buffer);

return _encryptedtext;

}/// /// 解密演算法

///

/// /// the encrypted text.

///

/// /// 解密字串

///

public string decrypt(string encryptedtext)

while (_bytesread > 0);

_buffer = _clearstream.getbuffer();

string _cleartext = encoding.utf8.getstring(_buffer, 0, (int) _clearstream.length);

return _cleartext;

}/// /// 加密

///

/// /// 連線字串

///

/// /// 金鑰

///

/// /// 加密後的字串

///

public static string encrypt(string cleartext, string key)

/// /// 解密

///

/// /// 連線字串

///

/// /// 金鑰

///

/// /// 解密後的字串

///

public static string decrypt(string encryptedtext, string key)

}

對稱加密 解密

加密 public static class encrypting 使用對稱演算法加密 public static string symmetricencrypts string str 如需指定加密演算法,可在create 引數中指定字串 create 方法中的引數可以是 des rc2 syst...

對稱加密與解密

using system using system.collections.generic using system.linq using system.text using system.io using system.security.cryptography namespace encrypt...

對稱加密解密類

using system using system.collections.generic using system.web using system.security.cryptography using system.text using system.io using system.web.u...