Support for the following algorithms by the SunJCE provider: 
DES 
DESede 
Blowfish 
PBEWithMD5AndDES 
PBEWithMD5AndTripleDES 
Diffie-Hellman key agreement among multiple parties 
HmacMD5 
HmacSHA1 

解决方案 »

  1.   

    Implementations and interfaces of ciphers, key agreements, MACs, etc. 
    Support for the following algorithms by the SunJCE provider: 
    DES 
    DESede 
    Blowfish 
    PBEWithMD5AndDES 
    PBEWithMD5AndTripleDES 
    Diffie-Hellman key agreement among multiple parties 
    HmacMD5 
    HmacSHA1 
      

  2.   

    但是Cryptix包中的Cipher也支持RSA吧,不然出错应该在cipher = Cipher.getInstance("RSA");此语句,但现在在最后一句 return cipher.crypt(data)出错.
      

  3.   

    use 
    Cipher.doFinal(cleartext);
      

  4.   

    一样出错:xjava.security.IllegalBlockSizeException: RSA: Non-padding cipher in ENCRYPT state with an incomplete final block
    我的原代码:import xjava.security.Cipher;
    import cryptix.provider.mode.*;
    import xjava.security.KeyGenerator;
    import java.security.*;
    import xjava.security.Mode;
    import xjava.security.*;
    public class Test {
      private static PublicKey pubkey;
      private static PrivateKey prikey;
      public static void main(String[] args)
      {
        byte[] data = new byte[30];
        for(int i = 0; i < 30; i++)
           data[i] = (byte)i;
        if(!createSecurtyKeys())
          return;
        byte[] edata = enCode(data,pubkey);
        if(edata ==null)  return;
        byte[] ddata = deCode(edata,prikey);
        if(ddata == null) return;
        for(int i = 0;i < ddata.length; i++)
          System.out.print(ddata[i]+"\t");
      }  public static boolean createSecurtyKeys()
      {
        try
        {
          SecureRandom secrand=new SecureRandom();
          java.security.KeyPairGenerator keygen=java.security.KeyPairGenerator.getInstance("RSA","Cryptix");
          keygen.initialize(512,secrand);     //初始化密钥生成器      KeyPair keys=keygen.generateKeyPair(); //生成密钥组
           pubkey = keys.getPublic();
           prikey = keys.getPrivate();
          /*把公共密钥和私有密钥分别保存于相应的文件中*/
          return true;
        }
        catch(Exception e)
        {
          System.out.println();
          return false;
        }
      }  public static byte[] enCode(byte[] data,Key key)
      {
          Cipher cipher = null;      
        try
        {
          cipher = Cipher.getInstance("RSA");
          cipher.initEncrypt(key);
          cipher.update(data);
          return cipher.doFinal(data);/**此处出错
          
        }
        catch(Exception e)
        {
          System.out.println(e);
          return null;
        }
      }  public static byte[] deCode(byte[] data,Key key)
      {
       Cipher cipher = null;
        try
        {
          cipher = Cipher.getInstance("RSA");
          cipher.initDecrypt(key);
          cipher.update(data);
          return cipher.doFinal(data);
        }
        catch(Exception e)
        {
          System.out.println("Decode Failure!");
          return null;
        }
      }
    }