|
@@ -1,8 +1,6 @@
|
|
package org.dromara.system.utils;
|
|
package org.dromara.system.utils;
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
|
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
|
import com.aliyun.teautil.models.RuntimeOptions;
|
|
import com.aliyun.teautil.models.RuntimeOptions;
|
|
|
|
|
|
@@ -22,11 +20,20 @@ public class SendSmsUtils {
|
|
StringBuilder code = new StringBuilder();
|
|
StringBuilder code = new StringBuilder();
|
|
for (int i = 0; i < num; i++) {
|
|
for (int i = 0; i < num; i++) {
|
|
int j = (int) (Math.random() * 10);
|
|
int j = (int) (Math.random() * 10);
|
|
- code.append(codes[j]);
|
|
|
|
|
|
+ if (j <= 0) {
|
|
|
|
+ j = 1;
|
|
|
|
+ }
|
|
|
|
+ code.append(codes[j - 1]);
|
|
|
|
+
|
|
}
|
|
}
|
|
return code.toString();
|
|
return code.toString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ String code = getCode(4);
|
|
|
|
+ System.out.println(code);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 使用AK&SK初始化账号Client
|
|
* 使用AK&SK初始化账号Client
|
|
*
|
|
*
|
|
@@ -50,7 +57,7 @@ public class SendSmsUtils {
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static String sendSms(String phone,String templateCode,String smsCode) {
|
|
|
|
|
|
+ public static String sendSms(String phone, String templateCode, String smsCode) {
|
|
String code = "";
|
|
String code = "";
|
|
try {
|
|
try {
|
|
// 工程代码泄露可能会导致AccessKey泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html
|
|
// 工程代码泄露可能会导致AccessKey泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html
|
|
@@ -78,7 +85,7 @@ public class SendSmsUtils {
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static String sendPassword(String password,String phone,String templateCode) {
|
|
|
|
|
|
+ public static String sendPassword(String password, String phone, String templateCode) {
|
|
String code = "";
|
|
String code = "";
|
|
try {
|
|
try {
|
|
// 工程代码泄露可能会导致AccessKey泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html
|
|
// 工程代码泄露可能会导致AccessKey泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html
|