C 3DES加密及弱金鑰處理

2021-07-22 05:13:04 字數 923 閱讀 1215

3des加密,以及避過.net弱金鑰檢測。**根據網上**進行的修改

private static byte threedes(byte key, byte str)

;//指定密匙長度,預設為192位

tdsc.keysize = 128;

//使用指定的key和iv(加密向量)

type t = type.gettype("system.security.cryptography.cryptoapitransformmode");

object obj = t.getfield("encrypt", bindingflags.instance | bindingflags.static | bindingflags.public | bindingflags.nonpublic | bindingflags.declaredonly).getvalue(t);

methodinfo mi = tdsc.gettype().getmethod("_newencryptor", bindingflags.instance | bindingflags.nonpublic);

icryptotransform descrypt = (icryptotransform)mi.invoke(tdsc, new object );

tdsc.iv = iv;

//加密模式,偏移

tdsc.mode = ciphermode.ecb;

//進行加密轉換運算

//icryptotransform ct = tdsc.createdecryptor();

//8很關鍵,加密結果是8位元組陣列

byte results = descrypt.transformfinalblock(str, 0, 8);

return results;

}

C 3DES加密解密

des3加密解密 public class des3 catch cryptographicexception e e.message return null des3 cbc模式解密 金鑰 iv 密文的byte陣列 明文的byte陣列 public static byte des3decodecb...

C 3DES加密解密,差點要了命

下面是c des3加密解密 public class des3 catch cryptographicexception e e.message return null des3 cbc模式解密 金鑰 iv 密文的byte陣列 明文的byte陣列 public static byte des3dec...

Des與3Des加密解密

des和3des演算法 public class des b ret.tostring return ret.tostring 3des加密 金鑰不能每8位重複,例如 123456781234567812345678,如果這樣則演算法退化為des,c 會檢測,不能使用 明文 金鑰 public st...