【发布时间】:2015-04-27 04:44:07
【问题描述】:
我有一个字符串 String x = "Sample text";,我想打印它的 base64 加密。正如许多例子所提到的,我使用:
byte[] encodedBytes = Base64.encodeBase64(x.getBytes());
System.out.println("encodedBytes " + new String(encodedBytes));
但这给了我The method encodeBase64(byte[]) is undefined for the type Base64...这是为什么呢?
【问题讨论】:
-
你的
Base64来自哪个包? -
嗯?我不知道那是什么意思...我只是按照建议添加了
import java.util.Base64;=/ -
Base64 不是加密,它是(二进制到文本)编码。