SHA256 PassHash

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:40, 11 July 2015
IstuntmanI (Talk | contribs)
(! Needs more informations ! (also, someone should make the 0.3.7 template to be able to specify the R2))
← Previous diff
Revision as of 20:28, 12 July 2015
Vince (Talk | contribs)

Next diff →
Line 1: Line 1:
{{Scripting}} {{Scripting}}
-{{AddedIn0.3.7|function|R2}}+{{AddedIn|0.3.7|R2|function}}
-{{Description|Hashes the password with the salt using SHA256 hash.}}+{{Description|Hashes a password using the SHA-256 hashing algorithm. Includes a salt. The output is always 256 bytes in length, or the equivalent of 64 Pawn cells.}}
{{Parameters|password[], salt[], ret_hash[], ret_hash_len}} {{Parameters|password[], salt[], ret_hash[], ret_hash_len}}
{{Param|password[]|The password to hash.}} {{Param|password[]|The password to hash.}}
-{{Param|salt[]|The salt to use in hash.}}+{{Param|salt[]|The [https://en.wikipedia.org/wiki/Salt_(cryptography) salt] to use in the hash.}}
{{Param|ret_hash[]|The returned hash.}} {{Param|ret_hash[]|The returned hash.}}
{{Param|ret_hash_len|The returned hash maximum length.}} {{Param|ret_hash_len|The returned hash maximum length.}}
-{{Returns|This function does not return any specific values.}}+{{NoReturn}}
 + 
 +{{Note|It is as of yet not yet known how the salt is applied internally. This is potentially problematic as it does not allow logins from other sources, such as a user control panel on your website.}}
{{Example}} {{Example}}
<pawn> <pawn>
-new MyHash[129]; 
- 
public OnGameModeInit() public OnGameModeInit()
{ {
 + new MyHash[64 + 1];
SHA256("test", "78sdjs86d2h", MyHash, sizeof MyHash); SHA256("test", "78sdjs86d2h", MyHash, sizeof MyHash);
printf("Returned hash: %s", MyHash); printf("Returned hash: %s", MyHash);

Revision as of 20:28, 12 July 2015


This function was added in SA-MP 0.3.7 R2 and will not work in earlier versions!


Description:

Hashes a password using the SHA-256 hashing algorithm. Includes a salt. The output is always 256 bytes in length, or the equivalent of 64 Pawn cells.


Parameters:
(password[], salt[], ret_hash[], ret_hash_len)
password[]The password to hash.
salt[]The salt to use in the hash.
ret_hash[]The returned hash.
ret_hash_lenThe returned hash maximum length.


Return Values:

This function does not return any specific values.


Image:32px-Ambox_warning_orange.png

Note

It is as of yet not yet known how the salt is applied internally. This is potentially problematic as it does not allow logins from other sources, such as a user control panel on your website.


Example Usage:

public OnGameModeInit()
{
    new MyHash[64 + 1];
    SHA256("test", "78sdjs86d2h", MyHash, sizeof MyHash);
    printf("Returned hash: %s", MyHash);
    return 1;
}