| | |
| | | import java.net.URLEncoder; |
| | | import java.security.Key; |
| | | import java.util.Base64; |
| | | import java.util.UUID; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | public class DESUtil { |
| | |
| | | public static String generateTokenToHk(String userName,Integer hour, RedisTemplate<String,Object> redisTemplate) { |
| | | long currentTimeMillis = System.currentTimeMillis() + 1000*60*60*hour; |
| | | String encrypt = DESUtil.encrypt("12345678",currentTimeMillis + "_" + userName ); |
| | | redisTemplate.opsForValue().set(Constants.REDIS_HK_TOKEN_KEY+encrypt, encrypt,1000*60*60*hour, TimeUnit.MILLISECONDS); |
| | | try{ |
| | | encrypt = URLEncoder.encode(encrypt,"UTF-8"); |
| | | // encrypt = Base64.getEncoder().encodeToString(encrypt.getBytes()); |
| | | // encrypt = URLEncoder.encode(encrypt,"UTF-8"); |
| | | }catch (Exception e){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"生成加密码失败!"); |
| | | } |
| | | return encrypt; |
| | | String token = UUID.randomUUID().toString(); |
| | | redisTemplate.opsForValue().set(Constants.REDIS_HK_TOKEN_KEY+token, encrypt,1000*60*60*hour, TimeUnit.MILLISECONDS); |
| | | return token; |
| | | } |
| | | |
| | | |