diff --git a/jwt/api_jws.py b/jwt/api_jws.py index 9b2d957f..125feab4 100644 --- a/jwt/api_jws.py +++ b/jwt/api_jws.py @@ -118,7 +118,7 @@ def encode( self, payload: bytes, key: AllowedPrivateKeys | PyJWK | str | bytes, - algorithm: str | None = None, + algorithm: str | None = "HS256", headers: dict[str, Any] | None = None, json_encoder: type[json.JSONEncoder] | None = None, is_payload_detached: bool = False, @@ -131,7 +131,7 @@ def encode( if isinstance(key, PyJWK): algorithm_ = key.algorithm_name else: - algorithm_ = "HS256" + algorithm_ = "none" else: algorithm_ = algorithm diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py index 418163a8..63a4a516 100644 --- a/jwt/api_jwt.py +++ b/jwt/api_jwt.py @@ -80,7 +80,7 @@ def encode( self, payload: dict[str, Any], key: AllowedPrivateKeyTypes, - algorithm: str | None = None, + algorithm: str | None = "HS256", headers: dict[str, Any] | None = None, json_encoder: type[json.JSONEncoder] | None = None, sort_headers: bool = True,