我在java中对中文汉字RSA加密,解密后有乱码怎么办?英文字符没有这种情况
有解决的办法么?
谢谢拉

解决方案 »

  1.   

    和加解密有关系,getbytes("gbk")也不行
    因为我要把字符串转成的byte转成biginteger,汉字的byte有cd,ef这种,所以转bigInteger的时候就会是复数,解密的时候就不准了
    有什么好办法么?
      

  2.   

    public static void main(String[] args) throws Exception {
    String s="1234567890我";
    BigInteger t=new BigInteger("244");
    BigInteger n=new BigInteger("2773");
    BigInteger d=new BigInteger("847");
    BigInteger e=new BigInteger("63");

    byte[] b=s.getBytes("gbk");
    BigInteger[] p=new BigInteger[b.length];
    for(int i=0;i<b.length;i++) {
    BigInteger z=new BigInteger(""+b[i]);
    p[i]=z.modPow(d, n);
    System.out.print(p[i].toString(16)+" ");
    }
    int lung=p.length;
    byte[][] r=new byte[lung][];
    for(int i=0;i<lung;i++) {
    System.out.print(p[i].modPow(e, n).toString(16)+" ");
    r[i]=p[i].modPow(e, n).toByteArray();
    }


    }
      

  3.   

    哈哈今天看到这么多次统一个问题了
    http://topic.csdn.net/u/20080531/10/1f55a89b-a198-4e5c-a768-35c88580ed28.html
    我已经解答