PHP的实现
# 示例一
echo md5('hello');
// 结果为:5d41402abc4b2a76b9719d911017c592
Nodejs的实现
# 示例一
let str = "hello";
const crypto = require('crypto');
let res = crypto.createHash('md5').update(str).digest("hex");
console.log(res);
// 结果:5d41402abc4b2a76b9719d911017c592
Python的实现
# 示例一
# encoding: utf-8
import md5
m = md5.new()
m.update('hello')
print m.hexdigest()
// 结果:5d41402abc4b2a76b9719d911017c592
# 示例二
# encoding: utf-8
import hashlib
m = hashlib.md5()
m.update('hello')
print m.hexdigest()
// 结果:5d41402abc4b2a76b9719d911017c592
Golang的实现
# 示例一
package main
import (
"crypto/md5"
"fmt"
"encoding/hex"
)
func main(){
md5Ctx := md5.New()
md5Ctx.Write([]byte("hello"))
cipherStr := md5Ctx.Sum(nil)
fmt.Print(hex.EncodeToString(cipherStr))
}
// 结果:5d41402abc4b2a76b9719d911017c592
网友评论