@Test void getpublicKey() throws NoSuchAlgorithmException, InvalidKeySpecException { bigIntModulus = new BigInteger("bcd32d940d9b013a26767c2a60817a275c688cce324f421e40cb4282bb4f914171c7d362d3ecd651c7391ab1999b1b8a440058a869b53c481d9482370d92afc97b2cb955beb214186a060913748140280e9ecbd4af9cac2765efbc6f7a4c5f5d7b2ab183e7eafd2950dd6425a3f386cb82b0a6fc3b2fe7006c9e1c1a665f28f2fdca56b68b14e622abbd7d9a338297a12a1767bb2066d3711c00e9bce485300fb7039e811ec2dda78fbed61047a93f9e6b82627679af87ab64e8d0480d1db4aee110b3423e599c73cddaa98dbfda93b0c6c7dca54a744e9ecbba2cce26aeba293003f03e6496242671c93368fa325cbe346244d7837aa2fdb4eb5e18fcfaf891",16); bigIntPrivateExponent =new BigInteger("10001",16); palaintext = "{\"latitude\":\"39.921094\",\"loginName\":\"13241847378\",\"deviceId\":\"fd40d837-7a47-340d-8047-d7882d47ff7f\",\"versionCode\":362,\"loginPwd\":\"903198FC13E1963F30834F0AE04A1ACF\",\"longitude\":\"116.419445 \",\"loginKind\":\"normal\"}"; cryptograph = "JC8dE6A/GaHt48dkk5QcpFPBh4sgW913s4CFjZIb/0RShdoHgNPHK22Ove11yES4/TE/d+jQXqApGEV4BKr9DsOC4MkOc1+BuUUQyXmzHvU5NQMHVN5U4EH++idWCJZqSU1IdV0cph5+kY4zX0+523Jh0TrzPnA1HeN7ilg3Xw9IWpa8Z/6nKA/yast DZz3tUzMhcDQvxsonN+Yfb/bIdMJxMvi0KKTnXjvAuISaehv49Ti5n1fv6M2O2awVz+6CMjY8OHn9mxhuivVQpryyK3Bj30VfYqSRtbTYNF0PI4OFUDFI6RFJWJD4G9OqCu8mHdhQYLEgYhH93ttnl2xDfQ=="; RSAPublicKeySpec keySpec = new RSAPublicKeySpec(bigIntModulus,bigIntPrivateExponent); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); RSAPublicKey rsaPublicKey = (RSAPublicKey) keyFactory.generatePublic(keySpec); byte[] result = null; result = RSAencryptionUtil.getInstance().encrypt(palaintext.getBytes(),rsaPublicKey); log.info("result 's value : {}", Base64.encodeToString(result)); result = RSAencryptionUtil.getInstance().encrypt(palaintext.getBytes(),rsaPublicKey); log.info("result 's value : {}", Base64.encodeToString(result)); }
public RSAPublicKey getpublicKey(Map<String, Object> keyMap){ RSAPublicKey publicKey = (RSAPublicKey) keyMap.get(HelperHolder.PUBLIC_KEY); return publicKey; }
RSAencryptionUtil { public RSAPublicKey getpublicKey(Map<String, Object> keyMap){ RSAPublicKey publicKey = (RSAPublicKey) keyMap.get(HelperHolder.PUBLIC_KEY); return publicKey; } }
RSAencryptionUtil { public RSAPublicKey getpublicKey(Map<String, Object> keyMap){ RSAPublicKey publicKey = (RSAPublicKey) keyMap.get(HelperHolder.PUBLIC_KEY); return publicKey; } private  RSAencryptionUtil(); }
RSAencryptionUtil { public RSAPublicKey getpublicKey(Map<String, Object> keyMap){ RSAPublicKey publicKey = (RSAPublicKey) keyMap.get(HelperHolder.PUBLIC_KEY); return publicKey; } private  RSAencryptionUtil(); static RSAencryptionUtil getInstance(); Map<String, Object> initKey(); RSAPublicKey getpublicKey(Map<String, Object> keyMap); RSAPrivateKey getPrivateKey(Map<String, Object> keyMap); byte[] encrypt(byte[] data, RSAPublicKey publicKey); byte[] decrypt(byte[] data, RSAPrivateKey privateKey); }
RSAencryptionUtil { public RSAPublicKey getpublicKey(Map<String, Object> keyMap){ RSAPublicKey publicKey = (RSAPublicKey) keyMap.get(HelperHolder.PUBLIC_KEY); return publicKey; } private  RSAencryptionUtil(); static RSAencryptionUtil getInstance(); Map<String, Object> initKey(); RSAPublicKey getpublicKey(Map<String, Object> keyMap); RSAPrivateKey getPrivateKey(Map<String, Object> keyMap); byte[] encrypt(byte[] data, RSAPublicKey publicKey); byte[] decrypt(byte[] data, RSAPrivateKey privateKey);  }