It should create the folder "CBhash".
You have the correct folder in the correct spot ?
All right then, launch Construct2.
This is how the icon of CB Hash looks in C2 object window. It is a beef. And some binary in the background. Yeah :)
Double-click this icon to include a CB Hash object to your project.
! Warning : CB Hash is a "single instance" object that won't appear on your layer. !
Now you're ready to use hashes.
+ Inline help
I've documented every function as clearly as I could. You can find informations at any point in the action and expression windows.
Add Action window:
Parameters for Action window:
Expression list:
Add event window:
Also here are the .capx from the CB Hash Demo Tech and CB Hash Demo Game.
CBhash Demo Tech.Capx[21]
CBhash Demo Game.Capx (See the topic, there is another plugin to download, all is explained).
Both .Capx are commented (as clearly and exhaustivly as I could).
+ So what's under the hood ?
The algorithms follow the same pattern.
You can obtain a straight hash by providing just the data to encode. You may obtain hexadecimal or base64 format output.
This is the simple method by the name of the algorithm.
You can obtain a sort of password by providing data to encode and a character string (ex:"123zreE519Fbfilmlzdpacujbn") whose characters only will appear in the final hash. (there won't be other characters in the hash than those).
This is the method Algorithmpass
You can obtain a HMAC type hash of the algorithm. You may obtain hexadecimal or base64 format output.
Both login and storing passwords require hashes that include both the password, and a random number (Key). We could simply hash the two strings concatenated. However, there is an alternative technique called HMAC, which uses two hash operations and some extra logic. This is specifically designed to be secure for such purposes, making it preferable to simple concatenation.
This is the method HMAC-Algorithm.
+ ACE table
Condition/event
The plugin offers one event: "On any hash generated", trigered any time a hash is made using either the actions or the expressions.
- Actions
Algorithm configuration
Set inner algorithm hexadecimal output format - The case of the letters A-F in hexadecimal output - Lowercase (default), Uppercase
Sets the inner algorithm hexadecimal output format - The character used to pad base-64 output to a multiple of 3 bytes - No Padding ("")(default), "="- for strict RFC compliance.
Those were supposed to be implemented as properties (not allowed in C2 at the moment for [i]pf_singleglobal[/i] objects).
You shouldn't really touch it (unless you have troubles synching the algorithm with the one of the server side).
MD5 Actions
MD5 - hash (String to encode, Output Format)
MD5 - password generation (String to encode, Character String)
HMAC-MD5 - keyed hashes (Key, String to encode, Output Format)
HMAC-MD5 - password generation ( Key, String to encode, Character String)
SHA-1 Actions
SHA-1 - hash (String to encode, Output Format)
SHA-1 - password generation (String to encode, Character String)
HMAC-SHA-1 - keyed hashes (Key, String to encode, Output Format)
HMAC-SHA-1 - password generation ( Key, String to encode, Character String)
SHA-256 Actions
SHA-256 - hash (String to encode, Output Format)
SHA-256 - password generation (String to encode, Character String)
HMAC-SHA-256 - keyed hashes (Key, String to encode, Output Format)
HMAC-SHA-256 - password generation ( Key, String to encode, Character String)
Expressions
"Hashed"
Get the last hash made. Command "get_lastResult", effect: Returns the last hash made.
"Hashing" MD5
Hash MD5 (Hexa). Command "MD5("data")", effect: MD5(Hexa) - Encodes the data provided with MD5 algorithm.
Hash MD5 (base64). Command "MD5B("data")", effect:MD5(base64) - Encodes the data provided with MD5 algorithm.
HMAC-MD5 Hash (Hexa). Command "HMACMD5(key,data)", effect:(Hexa) Encodes a data string using a string key in order to make a HMAC-MD5 (Hash-based Message Authentication Code) hash.
HMAC-MD5 Hash (base64). Command "HMACMD5B(key,data)", effect:(base64) Encodes a data string using a string key in order to make a HMAC-MD5 (Hash-based Message Authentication Code) hash.
"Password Generation"
MD5 password generation. Command "MD5pass(data,character string)", effect: Generate a password from data using only the characters from charstring.
HMAC-MD5 - password generation. Command "HMACMD5pass(key, data, character string)", effect: Generate an HMAC-MD5 (Hash-based Message Authentication Code) password using provided data, key and character string.
"Hashing" SHA-1
Hash SHA-1 (Hexa). Command "SHA1("data")", effect: SHA-1(Hexa) - Encodes the data provided with SHA-1 algorithm.
Hash SHA-1 (base64). Command "SHA1B("data")", effect:SHA-1(base64) - Encodes the data provided with SHA-1 algorithm.
HMAC-SHA-1 Hash (Hexa). Command "HMACSHA1(key,data)", effect:(Hexa) Encodes a data string using a string key in order to make a HMAC-SHA-1 (Hash-based Message Authentication Code) hash.
HMAC-SHA-1 Hash (base64). Command "HMACSHA1B(key,data)", effect:(base64) Encodes a data string using a string key in order to make a HMAC-SHA-1 (Hash-based Message Authentication Code) hash.
"Password Generation"
SHA-1 password generation. Command "SHA1pass(data,character string)", effect: Generate a password from data using only the characters from charstring.
HMAC-SHA-1 - password generation. Command "HMACSHA1pass(key, data, character string)", effect: Generate an HMAC-SHA-1 (Hash-based Message Authentication Code) password using provided data, key and character string.
"Hashing" SHA-256
Hash SHA-256 (Hexa). Command "SHA256("data")", effect: SHA-256(Hexa) - Encodes the data provided with SHA-256 algorithm.
Hash SHA-256 (base64). Command "SHA256B("data")", effect:SHA-256(base64) - Encodes the data provided with SHA-256 algorithm.
HMAC-SHA-256 Hash (Hexa). Command "HMACSHA256(key,data)", effect:(Hexa) Encodes a data string using a string key in order to make a HMAC-SHA-256 (Hash-based Message Authentication Code) hash.
HMAC-SHA-256 Hash (base64). Command "HMACSHA256B(key,data)", effect:(base64) Encodes a data string using a string key in order to make a HMAC-SHA-256 (Hash-based Message Authentication Code) hash.
"Password Generation"
SHA-256 password generation. Command "SHA256pass(data,character string)", effect: Generate a password from data using only the characters from charstring.
HMAC-SHA-256 - password generation. Command "HMACSHA256pass(key, data, character string)", effect: Generate an HMAC-SHA-256 (Hash-based Message Authentication Code) password using provided data, key and character string.
* The future/Extending the plugin
So as you can see, so far three algorithms coexist within the same plugin. And I believe we can put a lot more there.
The advantage of ectending with javascript, all you need is a notepad. No hard to set, time taking, software requiring compiling. You edit a fex text files, and here you have your plugin sitting in Construct2.
So this CornedBeef Hash could very well be extended by anyone of the community. And I urge you to do so. Please make it live, add it some other hashing useful algorithms.
I believe that JS allows such continuity. Let's try to keep a plugin per topic, but a very well featured plugin.
*I hope this tutorial helped you and that you will find some use for this hashes.
Thanks to Lucid for the name. Thanks to Zack0Wack0 for answering my first question in Javascript and looked upon the first implementation of this plugin.
And thanks to Ashley, Tom and every other person who ever worked on Construct Classic and Construct 2.*
CB Hash on the forum