springboot全家桶-springSecurity

1 MD5

package com.footprint.security.common;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 版权所有 (c) footprint 2021-2031
 * MD5 TODO
 *
 * @author footprint
 * @version 1.0.0
 * @since 2021/12/11 23:20
 */
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;

/**
 * 版权所有 (c) footprint 2021-2031
 * R TODO
 *
 * @author footprint
 * @version 1.0.0
 * @since 2021/12/11 23:31
 */
@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;

/**
 * 版权所有 (c) footprint 2021-2031
 * RedisConfig TODO
 *
 * @author footprint
 * @version 1.0.0
 * @since 2021/12/11 23:42
 */
@Configuration
public class RedisConfig {
   

//    @Bean
    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
   
        return new RedisTemplate<String, Object>();
    }

}

4 Response

package com.footprint.security.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值