q1mi / bluebell Goto Github PK
View Code? Open in Web Editor NEWbluebell
bluebell
在dao/mysql/user.go中有这样一段代码:
const secret = "liwenzhou.com"
func encryptPassword(data []byte) (result string) {
h := md5.New()
h.Write([]byte(secret))
return hex.EncodeToString(h.Sum(data))
}
h.Sum(data)的源码实现是先将直接将secret的MD5切片数组拼接到data切片数组后面,随后通过hex.EncodeToString转换成十六进制的字符串,这样返回的加密字符串并没有将明文的密码加密,而是返回了一个data字符串长度*2+32 长度的一个字符串。
例如假设data = []byte("123456")
,返回的result就为313233343536639a9119599647d841b1bef6ce5ea293
,去除后32位的字符的结果为:313233343536
,通过十六进制转字符串后的结果就是123456。也就是说,如果有人拿到了数据库中的password字段,就能获取到用户账户的明文信息。
可以修改成如下代码:
const secret = "liwenzhou.com"
func encryptPassword(data []byte) (result string) {
h := md5.New()
h.Write(append([]byte(secret),data...))
return hex.EncodeToString(h.Sum(nil))
}
这样返回的密文固定为32位字符串了。
db: bluebell_pre 应该改为 db: bluebell
前端的库版本能升级一下吗
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.