ソースを参照

添加了用户注册功能

Snow 2 週間 前
コミット
4a24cd5c79

+ 7 - 0
.idea/encodings.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
+  </component>
+</project>

+ 11 - 0
src/main/java/org/snowchen/GreatSonServer/Main.java

@@ -0,0 +1,11 @@
+package org.snowchen.GreatSonServer;
+
+import org.snowchen.GreatSonServer.programinit.UserInit;
+
+public class Main {
+    public static void main(String[] args) {
+
+        System.out.printf("Hello and welcome!");
+        UserInit userInit = new UserInit();
+    }
+}

+ 8 - 0
src/main/java/org/snowchen/GreatSonServer/databasecore/SQLiteConnect.java

@@ -0,0 +1,8 @@
+package org.snowchen.GreatSonServer.databasecore;
+
+
+public class SQLiteConnect {
+
+
+}
+

+ 7 - 0
src/main/java/org/snowchen/GreatSonServer/programinit/DataInput.java

@@ -0,0 +1,7 @@
+package org.snowchen.GreatSonServer.programinit;
+
+public class DataInput {
+    String user_name;
+    String password;
+    String UUID;
+}

+ 56 - 0
src/main/java/org/snowchen/GreatSonServer/programinit/UserInit.java

@@ -0,0 +1,56 @@
+package org.snowchen.GreatSonServer.programinit;
+
+import java.util.Arrays;
+import java.util.Scanner;
+import java.util.UUID;
+
+public class UserInit {
+    Scanner scan = new Scanner(System.in);
+    String user_name;
+    String password;
+    String uuid;
+    String [] UserData;
+
+    public UserInit() {
+        UserData = new String[3];
+        //用户信息初始化
+        System.out.println("请输入用户名:");
+        this.user_name = scan.nextLine();
+        while (this.user_name.isEmpty()) {
+            System.out.println("用户名不能为空,请重新输入:");
+            this.user_name = scan.nextLine();
+        }
+        UserData[0] = this.user_name;
+        System.out.println("请输入密码:");
+        this.password = scan.nextLine();
+        while (!isStrongPassword(this.password)) {
+            System.out.println("密码强度不够,请重新输入:");
+            this.password = scan.nextLine();
+        }
+        UserData[1] = this.password;
+        this.uuid = UUID.randomUUID().toString(); // 使用标准的 UUID 生成方法
+        UserData[2] = this.uuid;
+        System.out.println("用户名:" + this.user_name + "\n密码:" + this.password + "\nuuid:" + this.uuid);
+        System.out.println(Arrays.toString(UserData));
+
+
+    }
+
+    private static final String PWD_REGEX = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*()=_+;':,.?]).{8,}$";
+
+    /**
+     * 检测密码是否为强密码
+     * 强密码的定义基于预设的正则表达式PWD_REGEX,该表达式代表了密码的复杂性要求
+     *
+     * @param password 待检测的密码字符串
+     * @return 如果密码符合强密码的要求且不为空字符串,则返回true;否则返回false
+     */
+    public static boolean isStrongPassword(String password) {
+        //密码强度检测
+        if (password == null || password.trim().isEmpty()) {
+            return false;
+        }
+        return password.matches(PWD_REGEX);
+    }
+}
+

+ 0 - 17
src/main/java/org/snowchen/Main.java

@@ -1,17 +0,0 @@
-package org.snowchen;
-
-//TIP 要<b>运行</b>代码,请按 <shortcut actionId="Run"/> 或
-// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
-public class Main {
-    public static void main(String[] args) {
-        //TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
-        // 查看 IntelliJ IDEA 建议如何修正。
-        System.out.printf("Hello and welcome!");
-
-        for (int i = 1; i <= 5; i++) {
-            //TIP 按 <shortcut actionId="Debug"/> 开始调试代码。我们已经设置了一个 <icon src="AllIcons.Debugger.Db_set_breakpoint"/> 断点
-            // 但您始终可以通过按 <shortcut actionId="ToggleLineBreakpoint"/> 添加更多断点。
-            System.out.println("i = " + i);
-        }
-    }
-}