AppKey.java
910 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.teplot.sign;
import com.jfinal.kit.HashKit;
import com.jfinal.kit.StrKit;
/**
* Depiction:
* <p>
* Modify:
* <p>
* Author: Kevin Lynn
* <p>
* Create Date:2017年6月1日 上午12:49:39
*
*/
public class AppKey {
public static void main(String[] args) {
// String appKey = AppKey.getAppKey("concern-eyes");
String appKey = AppKey.getAppKey("benmengwang");
String appSecret = getAppSecret(appKey);
System.out.println(" appKey-->" + appKey);
System.out.println("appSecret-->" + appSecret);
}
public static String getAppKey(String salt) {
if (StrKit.isBlank(salt)) {
throw new RuntimeException("the salt is blank");
}
return HashKit.sha1(salt).substring(0, 16);
}
public static String getAppSecret(String appKey) {
if (StrKit.isBlank(appKey)) {
throw new RuntimeException("the appKey is blank");
}
return HashKit.sha1(appKey.substring(2, 10));
}
}