生成sha1签名时,加入参数判断

This commit is contained in:
Binary Wang
2017-06-10 17:19:10 +08:00
parent 26272bb7e5
commit 0fe431fc78
2 changed files with 41 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package me.chanjar.weixin.common.util.crypto;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
@@ -13,6 +14,10 @@ public class SHA1 {
* 串接arr参数生成sha1 digest
*/
public static String gen(String... arr) {
if (StringUtils.isAnyEmpty(arr)) {
throw new IllegalArgumentException("非法请求参数,有部分参数为空 : " + Arrays.toString(arr));
}
Arrays.sort(arr);
StringBuilder sb = new StringBuilder();
for (String a : arr) {