| | |
| | | * @return |
| | | */ |
| | | public String encryptedData(String plainText, String pub_key) { |
| | | log.error("需要加密的数据:{}", plainText); |
| | | log.info("需要加密的数据:{}", plainText); |
| | | try { |
| | | |
| | | byte[] publicKeyBytes = Base64.getDecoder().decode(pub_key); |
| | |
| | | |
| | | // 将加密后的数据转换为Base64编码的字符串 |
| | | String encryptedText = Base64.getEncoder().encodeToString(encryptedBytes); |
| | | log.error("Base64加密后的数据:{}", encryptedText); |
| | | log.info("Base64加密后的数据:{}", encryptedText); |
| | | encryptedText = URLEncoder.encode(encryptedText, StandardCharsets.UTF_8.toString()); |
| | | log.error("URLEncoder编码后的数据:{}", encryptedText); |
| | | log.info("URLEncoder编码后的数据:{}", encryptedText); |
| | | String decodedString = URLDecoder.decode(encryptedText, "UTF-8"); |
| | | log.error("URLEncoder解码后的数据:{}", decodedString); |
| | | log.info("URLEncoder解码后的数据:{}", decodedString); |
| | | return encryptedText; |
| | | } catch (Exception e) { |
| | | log.error("加密失败了:{}", e.getMessage()); |