Replace sha1 with sha256 to resolve #633

This commit is contained in:
oneumyvakin 2026-05-07 15:13:53 +07:00
parent a4d6cc5588
commit 9ed2ebe00d
1 changed files with 3 additions and 3 deletions

View File

@ -21,7 +21,7 @@ import socket
import ssl import ssl
import struct import struct
from base64 import b64encode from base64 import b64encode
from hashlib import sha1 from hashlib import sha256
from urllib.parse import urlparse from urllib.parse import urlparse
try: try:
@ -212,7 +212,7 @@ class WebSocket:
if accept is None: if accept is None:
raise Exception("Missing Sec-WebSocket-Accept header") raise Exception("Missing Sec-WebSocket-Accept header")
expected = sha1((self._key + self.GUID).encode("ascii")).digest() expected = sha256((self._key + self.GUID).encode("ascii")).digest()
expected = b64encode(expected).decode("ascii") expected = b64encode(expected).decode("ascii")
del self._key del self._key
@ -277,7 +277,7 @@ class WebSocket:
raise Exception("Missing Sec-WebSocket-Key header") raise Exception("Missing Sec-WebSocket-Key header")
# Generate the hash value for the accept header # Generate the hash value for the accept header
accept = sha1((key + self.GUID).encode("ascii")).digest() accept = sha256((key + self.GUID).encode("ascii")).digest()
accept = b64encode(accept).decode("ascii") accept = b64encode(accept).decode("ascii")
self.protocol = '' self.protocol = ''