{"id":22,"date":"2025-06-16T11:34:08","date_gmt":"2025-06-16T03:34:08","guid":{"rendered":"http:\/\/hhh3m.top\/?p=22"},"modified":"2026-04-08T17:26:24","modified_gmt":"2026-04-08T09:26:24","slug":"simple-verification-code","status":"publish","type":"post","link":"http:\/\/hhh3m.top\/index.php\/2025\/06\/16\/simple-verification-code\/","title":{"rendered":"\u7b80\u5355\u9a8c\u8bc1\u7801\u751f\u6210\u4e0e\u8c03\u7528"},"content":{"rendered":"\n<p>\u7b80\u5355\u751f\u6210\u9a8c\u8bc1\u7801\uff0c\u81ea\u5b9a\u4e49\u4f4d\u6570\u968f\u673a\u5927\u5c0f\u5199\u5b57\u6bcd\u6570\u5b57\u751f\u6210<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Random;\npublic class a {\n    public static void main(String&#91;] args) {\n\n        code(10);\n\n    }\n\n    public static void code(int n){\n       Random r=new Random();\n       for(int i=0;i&lt;n;i++){\n           \/\/\u51e0\u4f4d\u6570\n           int a=r.nextInt(3);\n           switch(a){\n               case 0:\/\/\u6570\u5b57\n                   int temp1=r.nextInt(10);\n                   System.out.print(temp1);\n                   break;\n               case 1:\/\/\u5c0f\u5199\u5b57\u6bcd\n                   char temp2 =(char)(r.nextInt(26)+97);\n                   System.out.print(temp2);\n                   break;\n               case 2:\/\/\u5927\u5199\u5b57\u6bcd\n                   char temp3 =(char)(r.nextInt(26)+65);\n                   System.out.print(temp3);\n                   break;\n               default:\/\/\u62a5\u9519\n                   System.out.print(\"\u51fa\u9519\u4e86\");\n                   break;\n           }\n       }\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u4fee\u6539\u683c\u5f0f\uff08ai\u7acb\u5927\u529f\u3002\u3002\uff09\u5b9e\u73b0\u63a5\u53d7\u9a8c\u8bc1\u7801\u957f\u5ea6\u53c2\u6570\u7684\u63a5\u53e3<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.example.demo;\n\nimport org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.RequestParam;\nimport org.springframework.web.bind.annotation.RestController;\nimport java.util.Random;\n\n@RestController\npublic class CaptchaController {\n    \n    @GetMapping(\"\/captcha\")\n    public String generateCaptcha(\n        @RequestParam(defaultValue = \"10\") int length\n    ) {\n        return generate(length);\n    }\n\n    public static String generate(int n) {\n        Random r = new Random();\n        StringBuilder sb = new StringBuilder();\n        for (int i = 0; i &lt; n; i++) {\n            int type = r.nextInt(3);\n            switch (type) {\n                case 0: \/\/ \u6570\u5b57\n                    sb.append(r.nextInt(10));\n                    break;\n                case 1: \/\/ \u5c0f\u5199\u5b57\u6bcd\n                    sb.append((char) (r.nextInt(26) + 97));\n                    break;\n                case 2: \/\/ \u5927\u5199\u5b57\u6bcd\n                    sb.append((char) (r.nextInt(26) + 65));\n                    break;\n            }\n        }\n        return \"\u9a8c\u8bc1\u7801: \" + sb.toString();\n    }\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/hhh3m.top\/wp-content\/uploads\/2025\/06\/image-1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"336\" data-original=\"http:\/\/hhh3m.top\/wp-content\/uploads\/2025\/06\/image-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-113\"  sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/div><\/figure>\n\n\n\n<div>\n    <span>\u6309\u7167\u4ee5\u4e0a\u7ed3\u6784\u521b\u5efa\u6587\u4ef6\u5728sprigboot\u6846\u67b6\u4e0b\u6253\u5305\u4e3ajar\u5305\u8fd0\u884c\uff0c\u8c03\u7528api\uff1a<\/span>\n    <a href=\"http:\/\/154.219.114.53:18080\/captcha?length=20\" target=\"_blank\"\n       style=\"display:inline-block; padding:6px 20px; background:#c100ff; color:white; text-decoration:none; border-radius:15px; margin-left: 10px;\">\n        \u7b80\u5355\u9a8c\u8bc1\u7801\u751f\u6210\n    <\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u5355\u751f\u6210\u9a8c\u8bc1\u7801\uff0c\u81ea\u5b9a\u4e49\u4f4d\u6570\u968f\u673a\u5927\u5c0f\u5199\u5b57\u6bcd\u6570\u5b57\u751f\u6210 \u4fee\u6539\u683c\u5f0f\uff08ai\u7acb\u5927\u529f\u3002\u3002\uff09\u5b9e\u73b0\u63a5\u53d7\u9a8c\u8bc1\u7801\u957f\u5ea6\u53c2\u6570\u7684\u63a5\u53e3 \u6309\u7167 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,2],"tags":[12,10],"class_list":["post-22","post","type-post","status-publish","format-standard","hentry","category-study","category-java_study","tag-java","tag-10"],"_links":{"self":[{"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/posts\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":36,"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":461,"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions\/461"}],"wp:attachment":[{"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hhh3m.top\/index.php\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}