mirror of
https://github.com/XZB-1248/Spark
synced 2025-10-05 16:16:49 +08:00
add: file upload
optimize: project structure
This commit is contained in:
@@ -36,6 +36,7 @@ func GetMD5(data []byte) ([]byte, string) {
|
||||
hash := md5.New()
|
||||
hash.Write(data)
|
||||
result := hash.Sum(nil)
|
||||
hash.Reset()
|
||||
return result, hex.EncodeToString(result)
|
||||
}
|
||||
|
||||
@@ -73,9 +74,13 @@ func Decrypt(data []byte, key []byte) ([]byte, error) {
|
||||
|
||||
hash, _ := GetMD5(decBuffer)
|
||||
if !bytes.Equal(hash, data[:16]) {
|
||||
data = nil
|
||||
decBuffer = nil
|
||||
return nil, ErrFailedVerification
|
||||
}
|
||||
data = nil
|
||||
decBuffer = decBuffer[:dataLen-16-64]
|
||||
|
||||
//fmt.Println(`Recv: `, string(decBuffer[:dataLen-16-64]))
|
||||
return decBuffer[:dataLen-16-64], nil
|
||||
return decBuffer, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user