8 changed files with 52 additions and 28 deletions
@ -0,0 +1,24 @@ |
|||
package com.youlai.boot.common.util; |
|||
|
|||
import cn.hutool.crypto.SecureUtil; |
|||
import cn.hutool.crypto.symmetric.AES; |
|||
|
|||
/** |
|||
* 瀑布流游标加解密,使用 AES 对称加密,隐藏内部自增主键 ID。 |
|||
*/ |
|||
public class CursorEncryptUtil { |
|||
|
|||
private static final byte[] AES_KEY = "CrsrK3y!2026_StrayAnimals_Proj".getBytes(java.nio.charset.StandardCharsets.UTF_8); |
|||
|
|||
private static final AES AES = SecureUtil.aes(AES_KEY); |
|||
|
|||
public static String encode(Long id) { |
|||
if (id == null) return null; |
|||
return AES.encryptBase64(String.valueOf(id)); |
|||
} |
|||
|
|||
public static Long decode(String cursor) { |
|||
if (cursor == null || cursor.isBlank()) return null; |
|||
return Long.parseLong(AES.decryptStr(cursor)); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue