Go to file
2024-11-26 15:22:06 +08:00
.gitignore first commit 2023-04-15 00:13:07 +08:00
base62json_test.go first commit 2023-04-15 00:13:07 +08:00
base62json.go first commit 2023-04-15 00:13:07 +08:00
go.mod [fix] git.fsdpf.net/go/base62 依赖更新 2024-11-26 15:22:06 +08:00
go.sum [fix] git.fsdpf.net/go/base62 依赖更新 2024-11-26 15:22:06 +08:00
README.md first commit 2023-04-15 00:13:07 +08:00

#base62json

brew install mingw-w64

编译 32位 dll
CGO_ENABLED=1 CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ GOOS=windows GOARCH=386 go build --buildmode=c-shared -ldflags="-s -w" -o main_x32.dll

编译 64位 dll
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ GOOS=windows GOARCH=amd64 go build --buildmode=c-shared -ldflags="-s -w" -o main_x64.dll
class Program 
{
    [DllImport("main", EntryPoint = "SetCharacters", CallingConvention = CallingConvention.Cdecl)]
    extern static bool SetCharacters(byte[] a);

    [DllImport("main", EntryPoint = "Encode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
    extern static IntPtr Encode(byte[] a);

    [DllImport("main", EntryPoint = "Decode", CallingConvention = CallingConvention.Cdecl)]
    extern static IntPtr Decode(byte[] test);

    static void Main(string[] args)
    {
            byte[] k = Encoding.ASCII.GetBytes("vY1lKxmABkMeRhV5q2XIEfT4ojuJdzaPcNUCs7Ft8GZnOW3Hip0LQ9gywrD6bS");

            bool bl = SetCharacters(k);

            string tmp = "{\"a\":1}";

            byte[] t = Encoding.ASCII.GetBytes(tmp);

            var b = Encode(t);

            tmp = Marshal.PtrToStringAnsi(b);

            t = Encoding.ASCII.GetBytes("m1jD8rjX5vYUmTMFSR8AgRDdvWPD8vdckSDPO0yfYrnEStBvMJBifXy1kUfE28AlDK0bYy8TVjdK02GyyZ7ck");

            var d = Decode(t);

            Console.WriteLine(Marshal.PtrToStringAnsi(d));
    }
}