sha1_string_unicode

Returns a sha1 hash of the unicode format input string.

Syntax:

GML Code Example

sha1_string_unicode(string)


Argument Description
string The string to hash.


Returns: String


Description

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:

GML Code 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.


Example:

GML Code Example

var hash, str;
 str = base64_encode(game_data);
 hash = sha1_string_unicode(str);
 http_get("http://www.MacSweeneyGames.com/CatchTheHaggis/gamedata?hash=" + hash); http_get("http://www.MacSweeneyGames.com/CatchTheHaggis/gamedata?data=" + 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.


Next: sha1_file



No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here