java RSA 加密解密,汉字乱码怎么办? 我在java中对中文汉字RSA加密,解密后有乱码怎么办?英文字符没有这种情况有解决的办法么?谢谢拉 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 和加解密有关系,getbytes("gbk")也不行因为我要把字符串转成的byte转成biginteger,汉字的byte有cd,ef这种,所以转bigInteger的时候就会是复数,解密的时候就不准了有什么好办法么? 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(); } } 哈哈今天看到这么多次统一个问题了http://topic.csdn.net/u/20080531/10/1f55a89b-a198-4e5c-a768-35c88580ed28.html我已经解答 大家有做JAVA图形/图像的不~~?? 谁给我看一下下面这个程序有问题吗? 求:《张孝祥IT课堂-Java教学视频录像(高级版)注册码~ JDK 1.5的问题 在java中怎么同步一个变量?就是对同一个变量同时只能一个进程读或写? 为什末我的IE不能支持java? 请问如何用jni类来调用一个非java写的外部exe?谢谢! 挑战~~~~~~~~~~~~~~~~~~~~~~~~~ 菜鸟求助,一个关于jdk的问题 关于swing JButton的icon不显示的问题 请问java1.3.1使用vrml97.jar的问题 Java 的可执行文件的制作
因为我要把字符串转成的byte转成biginteger,汉字的byte有cd,ef这种,所以转bigInteger的时候就会是复数,解密的时候就不准了
有什么好办法么?
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();
}
}
http://topic.csdn.net/u/20080531/10/1f55a89b-a198-4e5c-a768-35c88580ed28.html
我已经解答