golang md5 结果类型
golang md5 结果类型
package main import (
"crypto/md5"
"encoding/hex"
"fmt"
) func main() {
data := []byte("testing")
b := md5.Sum(data)
fmt.Println(string(b)) //错误,不能直接转 string
13 // fmt.Println(hex.EncodeToString(b[:]))
14 // fmt.Println(b[:])
}
# command-line-arguments
GoProjcet/src/exercise/test_md5.go:: cannot convert b (type []byte) to type string
Note:
Also note that converting a "random" slice of bytes to a string is most likely not what you want because a "random" slice of bytes may not be a valid UTF-8 byte sequence.
Instead use the encoding/hex package to convert the result to a hex string like this:
fmt.Println(hex.EncodeToString(b[:]))
package main import (
"crypto/md5"
"encoding/hex"
"fmt"
) func main() {
data := []byte("testing")
b := md5.Sum(data)
// fmt.Println(string(b))
fmt.Println(hex.EncodeToString(b[:]))
fmt.Println(b[:])
}
ae2b1fca515949e5d54fb22b8ed95575
[ ]
golang md5 结果类型的更多相关文章
- golang 函数作为类型
golang 函数作为类型 package main import "fmt" type A func(int, int) func (f A)Serve() { fmt.Prin ...
- 学习Golang语言(6):类型--切片
学习Golang语言(1): Hello World 学习Golang语言(2): 变量 学习Golang语言(3):类型--布尔型和数值类型 学习Golang语言(4):类型--字符串 学习Gola ...
- golang md5加密和python md5加密比较
python md5加密和golang md5加密各有不同,记录于此做备忘 Python 方法 md5 import base64 import hashlib def get_md5_data(bo ...
- Golang 的 `[]interface{}` 类型
Golang 的 []interface{} 类型 我其实不太喜欢使用 Go 语言的 interface{} 类型,一般情况下我宁愿多写几个函数:XxxInt, XxxFloat, XxxString ...
- Golang的值类型和引用类型的范围、存储区域、区别
常见的值类型和引用类型分别有哪些? 值类型:基本数据类型 int 系列, float 系列, bool, string .数组和结构体struct,使用这些类型的变量直接指向存在内存中的值,值类型的变 ...
- golang md5
package main import ( "crypto/md5" "encoding/hex" "fmt" "io" ...
- golang中函数类型
今天看Martini文档,其功能列表提到完全兼容http.HandlerFunc接口,就去查阅了Go: net/http的文档,看到type HandlerFunc这部分,顿时蒙圈了.由于之前学习的时 ...
- golang sync.noCopy 类型 —— 初探 copylocks 与 empty struct
问题引入 学习golang(v1.16)的 WaitGroup 代码时,看到了一处奇怪的用法,见下方类型定义: type WaitGroup struct { noCopy noCopy ... } ...
- [转]Golang之struct类型
http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=22312037&id=3756923 一.struct ...
随机推荐
- 用eclipse怎么打war包?
用eclipse怎么打war包? 在服务器上部署很多都是用war包进行部署的,eclipse是很友好的支持把java项目打成war包的,下面就把打war的经验写出来,供大家参考 百度经验:jingya ...
- 原生js格式化json和格式化xml的方法
在工作中一直看各位前辈的博客解决各种问题,对我的帮助很大,非常感谢! 之前一直比较忙没有写博客,终于过年有了点空闲时间,可以把自己积累的东西分享下,笔记中的部分函数不是自己写的,都是工作中一点点积累的 ...
- Python变量类型及变量
python是解释性语言 什么是解释性语言 就相当于你去饭店,你点了10道菜,他做好1道给你上1道.解释一行,执行一行.速度上不如编译性语言快. 什么是编译性语言 就相当于去饭店吃饭,你点了10道菜, ...
- 数据结构课后练习题(练习一)1007 Maximum Subsequence Sum (25 分)
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to ...
- Linux之目录与路径
特殊的目录: “.”,代表此层目录 “..”,代表上一层目录 “-”,代表前一个工作目录 “~”,代表“目前用户身份”所在的主文件夹 “~account”,代表account这个用户的主文件夹(acc ...
- 2017 BJ ICPC 石子合并变种 向量基本功及分类考察
E 模拟 #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) # ...
- Insomni'hack teaser 2019 - Misc - curlpipebash
参考链接 https://ctftime.org/task/7454 题目 Welcome to Insomni'hack teaser 2019! Execute this Bash command ...
- mybatis查询出字段为null,但是sql查出来有值
mybati 查出字段值为null, 然而相同的sql查出字段确实有值 原因: 在接受对象中使用了继承 :也就是说继承类与父类都定义了这个属性 ,字段重复,删除子类属性即可
- 1.docker容器技术基础入门
内容来自:https://www.cnblogs.com/marility/p/10215062.html https://blog.51cto.com/gouyc/2310785?source=dr ...
- 【LuoguP4156】论战捆竹竿
题目链接 题意简述 你有一个长度为 n 的字符串 , 将它复制任意次 , 复制出的串的前缀可以与之前的串的后缀重叠在一起 , 问最后总共可能的长度数目 , 长度不能超过 \(w\) 多组数据. \(n ...