diff --git a/pyrogram/client/methods/password/remove_cloud_password.py b/pyrogram/client/methods/password/remove_cloud_password.py
index 5a9875ff..a9320c39 100644
--- a/pyrogram/client/methods/password/remove_cloud_password.py
+++ b/pyrogram/client/methods/password/remove_cloud_password.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from hashlib import sha256
-
from pyrogram.api import functions, types
+from .utils import compute_check
from ...ext import BaseClient
@@ -31,25 +30,26 @@ class RemoveCloudPassword(BaseClient):
Your current password.
Returns:
- True on success, False otherwise.
+ True on success.
Raises:
:class:`Error ` in case of a Telegram RPC error.
+ ``ValueError`` in case there is no cloud password to remove.
"""
r = self.send(functions.account.GetPassword())
- if isinstance(r, types.account.Password):
- password_hash = sha256(r.current_salt + password.encode() + r.current_salt).digest()
+ if not r.has_password:
+ raise ValueError("There is no cloud password to remove")
- return self.send(
- functions.account.UpdatePasswordSettings(
- current_password_hash=password_hash,
- new_settings=types.account.PasswordInputSettings(
- new_salt=b"",
- new_password_hash=b"",
- hint=""
- )
+ self.send(
+ functions.account.UpdatePasswordSettings(
+ password=compute_check(r, password),
+ new_settings=types.account.PasswordInputSettings(
+ new_algo=types.PasswordKdfAlgoUnknown(),
+ new_password_hash=b"",
+ hint=""
)
)
- else:
- return False
+ )
+
+ return True