This commit is contained in:
adman
2025-12-15 22:07:37 +01:00
parent 01bf2a575c
commit 6108534a12
1118 changed files with 13788358 additions and 331 deletions
+36
View File
@@ -0,0 +1,36 @@
package bot
import (
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"github.com/google/uuid"
)
type SecureChatSession struct {
Account *Account
PlayerKeys PlayerKeys
Private *rsa.PrivateKey
SessionId uuid.UUID
}
func NewSecureChat(a *Account) (s *SecureChatSession, err error) {
s = &SecureChatSession{Account: a}
s.PlayerKeys, err = a.FetchKeys()
if err != nil {
return
}
block, _ := pem.Decode([]byte(s.PlayerKeys.KeyPair.PrivateKey))
k, err := x509.ParsePKCS8PrivateKey(block.Bytes)
if err != nil {
return
}
s.Private = k.(*rsa.PrivateKey)
s.SessionId, err = uuid.NewRandom()
return
}