1 MD5
package com.footprint.security.common;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public final class MD5 {
public static String encrypt(String strSrc) {
char hexChars[] = {
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
byte[] bytes = strSrc.getBytes();
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
md.update(bytes);
bytes = md.digest();
int j = bytes.length;
char[] chars = new char[j * 2];
int k = 0;
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
chars[k++] = hexChars[b >>> 4 & 0xf];
chars[k++] = hexChars[b & 0xf];
}
return new String(chars);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
}
}
2 R
package com.footprint.security.common;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
@Data
public class R {
private Boolean success;
private Integer code;
private String message;
private Map<String, Object> data = new HashMap<>();
private R() {
}
public static R ok() {
R r = new R();
r.setSuccess(true);
r.setCode(200);
r.setMessage("SUCCESS");
return r;
}
public static R error() {
R r = new R();
r.setSuccess(false);
r.setCode(201);
r.setMessage("FAIL");
return r;
}
public static R ok(Map<String, Object> data) {
R r = new R();
r.setSuccess(true);
r.setCode(200);
r.setData(data);
return r;
}
}
3 redis
package com.footprint.security.common;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
@Configuration
public class RedisConfig {
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
return new RedisTemplate<String, Object>();
}
}
4 Response
package com.footprint.security.