异常显示应该和你的编码无关吧好象是你的算法初始化的问题,你的Algorithm参数是怎么传的呢,看不出来有构造这个Algorithm的地方嘛

解决方案 »

  1.   

    Algorithm 是字符串String  Algorithm ="Blowfish";
      

  2.   

    Cipher c1 = Cipher.getInstance(Algorithm);
                                    ^^^^^^^^^
    最好指明Mode和Padding
    Cipher c1 = Cipher.getInstance("Blowfish/CBC/NoPadding");此外请注意你参数中传入的key的长度。
    首先jdk1.4中SunJCE缺省的Blowfish keysize已经调整了。
    ---------------
    SunJCE Default Blowfish Keysize Has Changed
    The SunJCE provider's default keysize for the Blowfish algorithm has changed from 56 bytes to 56 bits. 
    其次注意长度一定要是8的倍数,作为参数调用者是不一定传8倍数的长度的,所以接口开发者一定要自己作判断的。
    ------------------
    Blowfish: keysize must be a multiple of 8, and can only range from 32 to 448, inclusive 
      

  3.   

    我的key = "B8EA760CC575698B7AAF5AFADD72F639".getBytes()
      

  4.   

    如果真的不行的话,就用128位的算了。
    还可以使用bouncycastle的包,那个做得要比sun的好得多。
    http://www.bouncycastle.org/index.html
      

  5.   

    遇到同样问题,客户一定要使用md5加密后的字符串来作为Flowfish加密算法的密钥。md5加密后的字符串都是32字节字符串。报错:
    java.lang.SecurityException: Unsupported keysize or algorithm parameters
            at javax.crypto.Cipher.init(DashoA6275)
            at Crypt.encode(Crypt.java:30)
            at Crypt.main(Crypt.java:85)