AppKey.java 910 字节
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));
	}
}