protocol/encrypt: minor cleanup

This commit is contained in:
CPunch 2023-12-02 21:53:02 -06:00
parent 96eed66831
commit e257bf998f
1 changed files with 5 additions and 4 deletions

View File

@ -6,7 +6,7 @@ import (
)
const (
DEFAULT_KEY = "m@rQn~W#"
DEFAULT_KEY = "m@rQn~W#" // if you change this, make sure to update the test data in protocol_test.go
KEY_LENGTH = 8
)
@ -50,13 +50,14 @@ func DecryptData(buff, key []byte) {
}
func CreateNewKey(uTime, iv1, iv2 uint64) []byte {
dEKey := binary.LittleEndian.Uint64([]byte(DEFAULT_KEY))
num := iv1 + 1
num2 := iv2 + 1
dEKey := uint64(binary.LittleEndian.Uint64([]byte(DEFAULT_KEY)))
key := dEKey * (uTime * num * num2)
buf := make([]byte, 8)
binary.LittleEndian.PutUint64(buf, uint64(key))
binary.LittleEndian.PutUint64(buf, key)
return buf
}