@@ -0,0 +1,1873 @@
+package com.pjcdarker.util;%0A%0Aimport java.security.MessageDigest;%0Aimport java.security.NoSuchAlgorithmException;%0Aimport java.util.Arrays;%0Aimport java.util.Base64;%0Aimport java.util.Random;%0Aimport java.util.UUID;%0Aimport java.util.stream.Collectors;%0A%0A/**%0A * @author pjc%0A * @Created 12/20/2016.%0A */%0Apublic class Signature %7B%0A%0A    public static String generateToken() %7B%0A        String value = String.valueOf(System.currentTimeMillis());%0A        value += UUID.randomUUID().toString() + new Random().nextInt(10000);%0A        try %7B%0A            MessageDigest md = MessageDigest.getInstance(%22md5%22);%0A            byte%5B%5D b = md.digest(value.getBytes());%0A            return Base64.getEncoder().encodeToString(b); // %E7%94%9F%E6%88%90token%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A        return null;%0A    %7D%0A%0A%0A    public static String generateSignature(String token, String timestamp, String nonce) %7B%0A        String%5B%5D signatureArr = %7Btoken, timestamp, nonce%7D;%0A        Arrays.sort(signatureArr);%0A        String tmpStr = ArrayToString(signatureArr);%0A        tmpStr = sha1(tmpStr);%0A        return tmpStr;%0A    %7D%0A%0A    private static String ArrayToString(String%5B%5D strArr) %7B%0A        return Arrays.asList(strArr).stream().collect(Collectors.joining());%0A    %7D%0A%0A    private static String sha1(String source) %7B%0A        StringBuilder stringBuilder = new StringBuilder();%0A        try %7B%0A            MessageDigest md = MessageDigest.getInstance(%22SHA-1%22);%0A            byte%5B%5D bytes = md.digest(source.getBytes());%0A            for (byte b : bytes) %7B%0A                int t = b & 0xff;%0A                if (t %3C 0x10) %7B%0A                    stringBuilder.append(%220%22);%0A                %7D%0A                stringBuilder.append(Long.toString(t, 16));%0A            %7D%0A        %7D catch (NoSuchAlgorithmException e) %7B%0A            //%0A        %7D%0A        return stringBuilder.toString().toLowerCase();%0A    %7D%0A%7D%0A

add Signature