package com.sxy.rsademo; import com.sxy.rsademo.rsa.RsaUtils; import com.sxy.rsademo.utils.HttpClientUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import java.util.Map; @Slf4j @SpringBootApplication public class RsaDemoApplication { public static void main(String[] args) { SpringApplication.run(RsaDemoApplication.class, args); // 初始化密钥对,并持久化存储 RsaUtils.initKey(); try { // 获取持久化密钥对 Map<String,Object> keyMap = RsaUtils.getLastingKeyPair(); for (Map.Entry<String,Object> entry :keyMap.entrySet()){ log.info("keyMap==》 "+entry.getKey()+": "+entry.getValue()); } } catch (Exception e) { e.printStackTrace(); } // 发送数据进行测试 HttpClientUtils.main(args); } }
RsaDemoApplication.javapom.xml maven依赖文件: