问题描述
- java 代码内容如下(客户端要生成bin文件才能交互)求问 public.bin 文件如何生成的
-
public static void main(String[] args) throws Exception {
CertHelper help = CertHelper.getHttpCert();
Cert cert = new Cert("ticket", "8000", "http://127.0.0.1:8080/service/rbc.svc", "E:key8000public.bin", "gbk");
help.putCert(cert);Cert tcert = help.getCert("ticket"); System.out.println(tcert.getSignKey()); }
Cert cert = new Cert(....,...,....,..,..)加载文件 (E:key8000public.bin)
public void loadCert(String fileName) throws Exception { File file = new File(fileName); byte[] b = new byte[(int) file.length()]; FileInputStream fis = new FileInputStream(file); fis.read(b); fis.close(); ByteArrayInputStream bis = new ByteArrayInputStream(b); DataInputStream din = new DataInputStream(bis); int len = din.readInt(); keyBytes = new byte[len]; din.read(keyBytes); len = din.readInt(); modules = new byte[len]; din.read(modules); len = din.readInt(); byte[] ben = new byte[len]; din.read(ben); BigInteger message = new BigInteger(ben); setSignKey(new String(message.modPow(new BigInteger(keyBytes), new BigInteger(modules)).toByteArray())); }
解决方案
时间: 2025-01-07 15:13:58