From e257bf998ff28843d507d21f2d5feb9fa8f1aa95 Mon Sep 17 00:00:00 2001 From: CPunch Date: Sat, 2 Dec 2023 21:53:02 -0600 Subject: [PATCH] protocol/encrypt: minor cleanup --- cnet/protocol/encrypt.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cnet/protocol/encrypt.go b/cnet/protocol/encrypt.go index 8979e0c..f674116 100644 --- a/cnet/protocol/encrypt.go +++ b/cnet/protocol/encrypt.go @@ -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 }