关于加密算法DES/DESede/Blowfish的密钥位数
DES:算法DES要求密钥长度为64位密钥, 有效密钥56位。64bits=8*8*1,即8个ascii字符。
DESede:算法DESede要求的密钥位数为192位,即192bits=64*3=8*8*3,即24个ascii字符。
Blowfish:算法Blowfish要求密钥长度为8--448字位,即8--448(bits)。即:1个到56个ascii字符
DESede密钥位数不符合时的,报错如下:
java.security.InvalidKeyException: Wrong key size
at com.sun.crypto.provider.SunJCE_x.a(DashoA12275)
at com.sun.crypto.provider.SunJCE_i.a(DashoA12275)
at com.sun.crypto.provider.SunJCE_h.a(DashoA12275)
at com.sun.crypto.provider.SunJCE_h.a(DashoA12275)
at com.sun.crypto.provider.DESedeCipher.engineInit(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)
at com.yourCompany.CryptUtils.encrypt(CryptUtils.java:112)
at com.yourCompany.CryptUtils.encrypt(CryptUtils.java:144)
at com.yourCompany.CryptUtils.main(CryptUtils.java:260)
补充:综合编程 , 安全编程 ,