在Java中将字符串编码为base32字符串 [英] Encode string to base32 string in Java

查看:289
本文介绍了在Java中将字符串编码为base32字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像标题所说,我正在尝试将字符串test编码为Java中的base32字符串ORSXG5A =。

Just like the title says, I am trying to encode a string "test" into base32 string "ORSXG5A=" in Java.

我在网上搜索时找到的所有内容是从字符串到数组编码为32位的类,但显然这不是我想要的。

All I find when searching online is classes that encodes from string to array with 32bits, but obviously that is not what I want.

对于这个新手问题很抱歉。

Sorry for this newbie question.

推荐答案

Apache commons-codec 提供 Base32 类就是这样做

Apache commons-codec provides a Base32 class that does just that

Base32 base32 = new Base32();
System.out.println(base32.encodeAsString("test".getBytes()));

打印

ORSXG5A=

您可以下载这里

这篇关于在Java中将字符串编码为base32字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆