Returns a sha1 hash of the unicode format input string.



Argument Description
string The string to hash.

Returns: String


In cryptography, SHA-1 is a cryptographic hash function designed by the United States National Security Agency and is employed in several widely used applications and protocols like the popular Git where it is used to check for file changes. This function will take an input unicode string and returns a 160 bit message digest in ASCII format, for example:

sha1 input string = "The quick brown fox jumps over the lazy dog"
sha1 output hash = "2fd4e1c6 7a2d28fc ed849ee1 bb76e739 1b93eb12"

In this way you can generate a secure key which can be stored and used to check the integrity of the information being sent to (or received from) an external server (for example).

NOTE: There are two formats for the sha1 encoding, UTF-8 and unicode. Both are provided to facilitate communication with different server setups, but the most common to use is unicode.


var hash, str;
str = base64_encode(game_data);
hash = sha1_string_unicode(str);
http_get("" + hash); http_get("" + str);

The above code will base64 encode a string and then generate a sha1 hash. Finally, both the hash and the encoded string are sent to a server.

Back: File Handling
Next: sha1_file
© Copyright YoYo Games Ltd. 2018 All Rights Reserved