C# Method like Base64String, but only alphanumeric (no plus or slash)

前端 未结 6 893
清歌不尽
清歌不尽 2021-02-13 11:25

is there any C# method that works similar to Convert.ToBase64String but doesn\'t generate anything except alphanumeric output?

Thanks!

6条回答
  •  萌比男神i
    2021-02-13 11:59

    I was searching for a such like encoder and I used https://github.com/renmengye/base62-csharp/

    It's an encoder/decoder in "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" character space range.

    I just wrapped its methods with

    System.Text.Encoding.UTF8.GetBytes(plainText); and System.Text.Encoding.UTF8.GetString(decoded);

    calls to allow it to work easily with strings.

提交回复
热议问题