資源簡介
代碼片段和文件信息
package?com.des;
import?android.annotation.SuppressLint;
import?java.security.SecureRandom;
import?javax.crypto.Cipher;
import?javax.crypto.SecretKey;
import?javax.crypto.SecretKeyFactory;
import?javax.crypto.spec.DESKeySpec;
@SuppressLint(“DefaultLocale“)
public?class?DES
{
????public?DES()
????{
????}
????//?測試
????/**
?????*?把16進制字符串轉換成字節數組
?????*?
?????*?@param?hex
?????*?@return
?????*/
????public?static?byte[]?hexStringToByte(String?hex)
????{
int?len?=?(hex.length()?/?2);
byte[]?result?=?new?byte[len];
char[]?achar?=?hex.toCharArray();
for?(int?i?=?0;?i? {
????int?pos?=?i?*?2;
????result[i]?=?(byte)?(toByte(achar[pos])?<4?|?toByte(achar[pos?+?1]));
}
return?result;
????}
????private?static?byte?toByte(char?c)
????{
b
評論
共有 條評論