程式開發中常用的加加密類

2021-04-29 14:32:08 字數 1243 閱讀 8245

/*

* 功能:系統的sha1加密 ,此類的功能與md5一樣,都是不可逆,經常用於口令密碼的配對。

*/using system;

using system.collections.generic;

using system.text;

using system.security.cryptography;

using system.io;

///

/// 功能:系統的sha1加密

///

public class sha1helper

return this.getsha1string(source).equals(entstr);

}public string getsha1string(string strsource)

}///

/// 系統加密類

///

public class md5encrypt

///

/// 比較是否相等

///

/// 要加密的串

/// 加密之後的串

/// true:相等

public static bool comparehash(string source, string entstr)

return md5(source).equals(entstr);}}

//3des加密類,此加密演算法可逆,經常用於對部分資料的加密及解密,例如需要進行網路傳輸的資料等。

public class descryptohelper

;private string skey;

// methods

public descryptohelper()

public descryptohelper(string key)

public string desdecrypt(string value)

public string desencrypt(string value)

///

/// 得到解密之後的字串

///

///

///

public string getdesstring(string value)

///

/// 得到加密之後的口字串

///

///

///

public string getencstring(string value)

}

iOS開發中常用到的加密方式

1 base64 1.1 簡介 base64編碼的思想是是採用64個基本的ascii碼字元對資料進行重新編碼。它將需要編碼的資料拆分成位元組陣列。以3個位元組為一組。按順序排列24位資料,再把這24位資料分成4組,即每組6位。再在每組的的最高位前補兩個0湊足乙個位元組。這樣就把乙個3位元組為一組的資...

iOS開發中常用到的加密方式

1 base64 1.1 簡介 base64編碼的思想是是採用64個基本的ascii碼字元對資料進行重新編碼。它將需要編碼的資料拆分成位元組陣列。以3個位元組為一組。按順序排列24位資料,再把這24位資料分成4組,即每組6位。再在每組的的最高位前補兩個0湊足乙個位元組。這樣就把乙個3位元組為一組的資...

梳理開發中常用的加密演算法

在資料傳輸的過程中,首先把密碼類資料經過md5加密演算法加密,然後再在外面使用可逆的加密方式加密一次,這樣在資料傳輸的過程中,即便資料被截獲了,但是想要完全破解,還是很難的。hash演算法特別的地方在於它是一種單向演算法,使用者可以通過hash演算法對目標資訊生成一段特定長度的唯一的hash值,卻不...