当前位置:网站首页>mysql数据库中的数据如何加密呢?mysql8.0自带新特性
mysql数据库中的数据如何加密呢?mysql8.0自带新特性
2022-07-27 17:20:00 【运维家】

===============================================================================================================================================================================
加密函数主要用来对数据进行加密和界面处理,以保证某些重要数据不被别人获取。
加密函数MD5(str)
md5(str)字符串算出一个md5 128比特校验和。
该值以32位十六进制数字的二进制字符串形式返回,如果参数是null,则返回的值就是null;
mysql> select md5('yunweijia'), length(md5('yunweijia'));
+----------------------------------+--------------------------+
| md5('yunweijia') | length(md5('yunweijia')) |
+----------------------------------+--------------------------+
| e1c2c47c0b1d8ca6076030bf8e8ea42a | 32 |
+----------------------------------+--------------------------+
1 row in set (0.00 sec)
mysql>
可以看到确实是返回了一个32位长度的十六进制数字的字符串。
加密函数SHA(str)
SHA(str)从原明文密码str计算并返回加密后的密码字符串,当参数为null的时候,返回的值也就是null。
SHA加密算法相对于MD5加密算法,会更加安全。
mysql> select sha('yunweijia');
+------------------------------------------+
| sha('yunweijia') |
+------------------------------------------+
| 683501978a90d76d420b893cd7e00c8efde8e8f3 |
+------------------------------------------+
1 row in set (0.00 sec)
mysql>
加密函数SHA2(str, hash_length)
SHA2(str, hash_length):使用hash_length作为长度,加密字符串str;
hash_length支持的值为:224、256、384、512和0,为什么会有0呢,如果是0的话,就相当于是256了。
mysql> select sha2('yunweijia', 256) as A, sha2('yunweijia', 0) as B\G;
*************************** 1. row ***************************
A: 1c60cca8fb0ef62bbf751245f72bbb7c308d59d773214133dc6051cd4acd0b64
B: 1c60cca8fb0ef62bbf751245f72bbb7c308d59d773214133dc6051cd4acd0b64
1 row in set (0.00 sec)
ERROR:
No query specified
mysql>
从上面的运行结果可以看到哈,当我们的hash_length的值为256和0时,他们两个的结果是一致的。
至此,本文结束。
更多内容请转至VX公众号 “运维家” ,获取最新文章。
------ “运维家” ------
------ “运维家” ------
------ “运维家” ------
linux中断异常,linuxuml建模,linux编译多个源文件,linux怎么更新时间,linux中的分页视频教程,
linux怎么解压gzip,linux解压某个目录,怎么关闭linux网关,linux文件架构图,linux提高权限执行,
linux文件用什么标志,网络安全linux加固,linux中查看邮件,linux修改背景颜色,linux环境下搭建网站。
边栏推荐
猜你喜欢

软件配置 | tigerVNC的下载、安装及配置

GestureDetector(手势识别)

Flink introduction and operation architecture

Oracle XE版安装与用户操作

Use of jvisualvm

No experts! Growth secrets for junior and intermediate programmers and "quasi programmers" who are still practicing in Universities

ContentProvider of four components

Intent(有无返回值得跳转)

黑客入门教程(非常详细)从零基础入门到精通,看完这一篇就够了。

Release Samsung 3J1 sensor: the code implies that the safety of pixel 7 face recognition will be greatly increased
随机推荐
容器总结
2022爱分析·智慧社区厂商全景报告 厂商征集
Binary search tree
常见运算符9.21
NAT 11.16
AutoCompleteTextView(输入框预匹配)
归一化(Normalization)和标准化(Standardization)
Oracle 日期的转换
Turn Hyper-V on and off
What's new in helix QAC 2022.2, the ace code static testing tool (2)
贪心
[daily accumulation - 06] view CUDA and cudnn versions
11.2DHCP
Can go to QQ but can't open the web page
疫情下我离职一年,收入增长了10倍
GridView(实现表格显示图标)
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xff in position 0: invalid start byte
JS 事件监听 鼠标 键盘 表单 页面 onclick onkeydown onChange
10.31静态路由的扩展配置
How powerful can top "hackers" be? Internet access without signal, expert: high-end operation!