package com.ruoyi.cms.util;

import java.util.Base64;

public class Base64Util {
    public static String longIdToBase64(long id) {
        // 将 Long 转换为字节数组
        byte[] bytes = new byte[8];
        bytes[0] = (byte) (id >> 56);
        bytes[1] = (byte) (id >> 48);
        bytes[2] = (byte) (id >> 40);
        bytes[3] = (byte) (id >> 32);
        bytes[4] = (byte) (id >> 24);
        bytes[5] = (byte) (id >> 16);
        bytes[6] = (byte) (id >> 8);
        bytes[7] = (byte) id;

        // 使用 Base64 编码
        return Base64.getEncoder().encodeToString(bytes);
    }

    public static void main(String[] args) {

        System.out.println(Base64.getEncoder().encodeToString(String.valueOf(118154768l).getBytes()));
    }
}
