- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章java使用Base64编码实例由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
本文实例为大家分享了java使用base64编码的具体代码,供大家参考,具体内容如下 。
test base64 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package
com.weiwen.provider.utils;
import
java.io.ioexception;
import
com.alibaba.fastjson.json;
import
lombok.extern.slf4j.slf4j;
import
org.junit.test;
import
sun.misc.base64encoder;
import
sun.misc.base64decoder;
@slf4j
public
class
base64 {
@test
public
void
testbase64()
throws
ioexception {
// base64编码
string s =
"1f2bc1970a2eb19aabc0f94acea922717a1ae998603ff0593baff"
;
base64encoder encoder =
new
base64encoder();
s = encoder.encode(s.getbytes(
"utf-8"
));
// system.out.println(s);
log.info(
"base64编码为:{}"
, json.tojsonstring(s));
// base64解码
base64decoder decoder =
new
base64decoder();
byte
[] bytes = decoder.decodebuffer(s);
// system.out.println(new string(bytes, "utf-8"));
log.info(
"base64解码为:{}"
, json.tojsonstring(
new
string(bytes,
"utf-8"
)));
}
}
|
base64工具类 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package
com.weiwen.provider.utils;
import
java.io.ioexception;
import
com.alibaba.fastjson.json;
import
lombok.extern.slf4j.slf4j;
import
org.junit.test;
import
sun.misc.base64encoder;
import
sun.misc.base64decoder;
@slf4j
public
class
base64 {
/**
* base64 编码
* @param encodetext
* @return
* @throws ioexception
*/
public
static
string base64encode(string encodetext)
throws
ioexception{
base64encoder encoder =
new
base64encoder();
string str = encoder.encode(encodetext.getbytes(
"utf-8"
));
log.info(
"base64编码为:{}"
, json.tojsonstring(str));
return
str;
}
/**
* base64 解码
* @param decodetext
* @return
* @throws ioexception
*/
public
static
byte
[] base64decode(string decodetext)
throws
ioexception{
base64decoder decoder =
new
base64decoder();
byte
[] bytes = decoder.decodebuffer(decodetext);
log.info(
"base64解码为:{}"
, json.tojsonstring(
new
string(bytes,
"utf-8"
)));
return
bytes;
}
}
|
以上所述是小编给大家介绍的java使用base64编码详解整合,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我网站的支持! 。
原文链接:https://blog.csdn.net/weixin_42740530/article/details/88249641 。
最后此篇关于java使用Base64编码实例的文章就讲到这里了,如果你想了解更多关于java使用Base64编码实例的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
如果我不定义自己的构造函数,Base *b = new Base; 与 Base *b = new Base(); 之间有什么区别吗? 最佳答案 初始化是标准中要遵循的一种 PITA...然而,这两个
是否有现成的函数可以在 C# 中进行基本转换?我希望将以 26 为基数和以 27 为基数的数字转换为以 10 为基数。我可以在纸上完成,但我不是一个非常有经验的程序员,如果可能的话,我宁愿不要从头开始
JNA 中'base'是什么意思 Pointer.getPointerArray(long base) Pointer.getStringArray(long base) ? JNA Document
我正在做一个将数字从 10 进制转换为 2 进制的基本程序。我得到了这段代码: #include #include #include #include using namespace std;
“假设以下代码: public class MultiplasHerancas { static GrandFather grandFather = new GrandFather();
当我分析算法的时候,我突然问自己这个问题,如果我们有三元计算机时间复杂度会更便宜吗?还是有任何基础可以让我们构建计算机,这样时间复杂度分析就无关紧要了?我在互联网上找不到太多,但是基于三元的计算机在给
一个简化的场景。三个类,GrandParent,Parent 和 Child。我想要做的是利用 GrandParent 和 Parent 构造函数来初始化一个 Child 实例。 class Gran
我编写了一个简单的函数来将基数为 10 的数字转换为二进制数。我编写的函数是我使用我所知道的简单工具的最佳尝试。我已经在这个网站上查找了如何执行此操作的其他方法,但我还不太了解它。我确定我编写的函数非
我尝试了以下代码将数字从 base-10 转换为另一个 base。如果目标基地中没有零(0),它就会工作。检查 79 和 3 并正确打印正确的 2221。现在尝试数字 19 和 3,结果将是 21 而
这个问题在这里已经有了答案: Is Big O(logn) log base e? (7 个答案) 关闭 8 年前。 Intro 练习 4.4.6 的大多数解决方案。算法第三版说,n*log3(n)
如何判断基类(B)的指针是否(多态)重写了基类的某个虚函数? class B{ public: int aField=0; virtual void f(){}; }; class C
我测试了这样的代码: class A { public A() { } public virtual void Test () { Console.WriteL
两者都采用相同的概念:定义一些行和列并将内容添加到特定位置。但是 Grid 是最常见的 WPF 布局容器,而 html 中基于表格的布局是 very controversial .那么,为什么 WPF
我试图在 JS 中“获得”继承。我刚刚发现了一种基本上可以将所有属性从一个对象复制到另一个对象的简洁方法: function Person(name){ this.name="Mr or Miss
class A { public override int GetHashCode() { return 1; } } class B : A { pu
我有一个 Base32 信息哈希。例如IXE2K3JMCPUZWTW3YQZZOIB5XD6KZIEQ ,我需要将其转换为base16。 我怎样才能用 PHP 做到这一点? 我的代码如下所示: $ha
我已经使用其实验界面对 Google Analytics 进行了一些实验,一切似乎都运行良好,但我无法找到 Google Analytics 属性如何达到变体目标的答案,即归因 session - 基
if (state is NoteInitial || state is NewNote) return ListView.builder(
MSVC、Clang 和 GCC 不同意此代码: struct Base { int x; }; struct Der1 : public Base {}; struct Der2 : public
我已经尝试构建一个 Base 10 到 Base 2 转换器... var baseTen = window.prompt("Put a number from Base 10 to conver
我是一名优秀的程序员,十分优秀!