101 lines
2.3 KiB
Markdown
101 lines
2.3 KiB
Markdown
---
|
|
title: danog\MadelineProto\MTProtoTools\PasswordCalculator: Manages SRP password calculation.
|
|
description:
|
|
|
|
---
|
|
# `danog\MadelineProto\MTProtoTools\PasswordCalculator`
|
|
[Back to index](../../../index.md)
|
|
|
|
> Author: Daniil Gentili <daniil@daniil.it>
|
|
|
|
|
|
Manages SRP password calculation.
|
|
|
|
|
|
|
|
|
|
---
|
|
Generated by [danog/phpdoc](https://phpdoc.daniil.it).
|
|
## Method list:
|
|
* `addInfo(array $object): void`
|
|
* `createSalt(string $prefix): \string Salt`
|
|
* `hashSha256(string $data, string $salt): \string Hash`
|
|
* `hashPassword(string $password, string $client_salt, string $server_salt): \string Resulting hash`
|
|
* `getCheckPassword(string $password): \array InputCheckPassword object`
|
|
* `getPassword(array $params): \array account.updatePasswordSettings parameters`
|
|
|
|
## Methods:
|
|
### `addInfo(array $object): void`
|
|
|
|
Popupate 2FA configuration.
|
|
|
|
|
|
Parameters:
|
|
* `$object`: `array` 2FA configuration object obtained using account.getPassword
|
|
|
|
|
|
|
|
### `createSalt(string $prefix): \string Salt`
|
|
|
|
Create a random string (eventually prefixed by the specified string).
|
|
|
|
|
|
Parameters:
|
|
* `$prefix`: `string` Prefix
|
|
|
|
|
|
Return value: Salt
|
|
|
|
|
|
### `hashSha256(string $data, string $salt): \string Hash`
|
|
|
|
Hash specified data using the salt with SHA256.
|
|
The result will be the SHA256 hash of the salt concatenated with the data concatenated with the salt
|
|
|
|
Parameters:
|
|
* `$data`: `string` Data to hash
|
|
* `$salt`: `string` Salt
|
|
|
|
|
|
Return value: Hash
|
|
|
|
|
|
### `hashPassword(string $password, string $client_salt, string $server_salt): \string Resulting hash`
|
|
|
|
Hashes the specified password.
|
|
|
|
|
|
Parameters:
|
|
* `$password`: `string` Password
|
|
* `$client_salt`: `string` Client salt
|
|
* `$server_salt`: `string` Server salt
|
|
|
|
|
|
Return value: Resulting hash
|
|
|
|
|
|
### `getCheckPassword(string $password): \array InputCheckPassword object`
|
|
|
|
Get the InputCheckPassword object for checking the validity of a password using account.checkPassword.
|
|
|
|
|
|
Parameters:
|
|
* `$password`: `string` The password
|
|
|
|
|
|
Return value: InputCheckPassword object
|
|
|
|
|
|
### `getPassword(array $params): \array account.updatePasswordSettings parameters`
|
|
|
|
Get parameters to be passed to the account.updatePasswordSettings to update/set a 2FA password.
|
|
The input params array can contain password, new_password, email and hint params.
|
|
|
|
Parameters:
|
|
* `$params`: `array` Input params
|
|
|
|
|
|
Return value: account.updatePasswordSettings parameters
|
|
|
|
|