whycxzp
2023-11-10 f7fc92f670c326570e1c5411135c45ac9e97c80e
修复
2个文件已修改
15 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/InterFaceController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/InterfaceService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/InterFaceController.java
@@ -10,6 +10,7 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
@RequestMapping("interface")
@@ -99,7 +100,7 @@
    @GetMapping("/createInterface")
    @ApiOperation("生成第三方验证码")
    public Response createInterface(@RequestParam String interfaceName) {
    public Response createInterface(@RequestParam String interfaceName) throws NoSuchAlgorithmException {
        return service.createInterface(interfaceName);
    }
src/main/java/com/whyc/service/InterfaceService.java
@@ -295,7 +295,7 @@
    }
    //生成第三方验证码
    public Response createInterface(String interfaceName) {
    public Response createInterface(String interfaceName) throws NoSuchAlgorithmException {
        String random = getRandomString(25);
        //rsa加密
        String encryptRandom = RSAUtil.encrypt(random, RSAUtil.getPublicKey());
@@ -336,15 +336,11 @@
    }
    //length用户要求产生字符串的长度
    public static String getRandomString(int length) {
    public static String getRandomString(int length) throws NoSuchAlgorithmException {
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        //Random random = new Random();
        SecureRandom random = null;
        try {
            random = SecureRandom.getInstance("SHA1PRNG");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        SecureRandom  random = SecureRandom.getInstance("SHA1PRNG");
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(62);