문제

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

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 provides a Base32 class that does just that

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

prints

ORSXG5A=

You can download it here.

다른 팁

As @Sotirios Delimanolis wrote it can be done using apache commons but you can also use google guava libraries. For example:

BaseEncoding.base32().encode("test".getBytes());

will return ORSXG5A=.

More information can be found here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top