[Plugin][Work in progress]MD5 Encryption

0 favourites
  • 9 posts
  • <font color="blue">This is a work in progress, the current plugin is broken.</font>

    http://dl.dropbox.com/u/36472942/construct/plugin/wip/md5_0.e.zip

    I've been working on turning a JS implementation of the MD5 algorithm into a plugin.

    Basicly, it is an expression that allows you to encrypt the data you feed it with into hexadecimal MD5.

    I've had a previous version that worked. (You might try it and use it if you want)

    As the implementation of the algorithm has several output formats (hexa, base64 and even allows different types of encryption in the spectrum of the same functions use) I'm working on allowing the user to choose between them.

    At the moment I'm stuck, as I've been adding properties to my object. And now, in the runtime, firebug tells me that "this.properties" isn't defined, blocking the whole process.

    Well, it is in my edittime.js though.

    (My test project is an object MD5 and an object text. On startup of layout, I set Text.text to MD5.Encrypt("Hello world !").)

    I've used the structure/code from the plugin text to guide me. I've also looked in about all of the plugins code, and it seems to me they are all following the same pattern.

    Right now, I can't seem to find what's wrong. I'll look over it later (and/or tommorrow) but if in the mean time the community can bring me an answer i'll be more than happy ^^

    I'm still new to JS, and mainly learning it by going through C2's plugins and behaviors folders ^^ (looking a bit over jquery's documentation for future plugins too)

    Edit: I'll favor the occasion to suggest an option in C2 that allows to reload/rehash the plugins and behaviors (if it is possible). As of now, on any change on my plugin, I have to quit and launch again the editor, and set up my test project (save/load can't really work as any change on the plugins makes old saves incompatible). Doable, but tedious. If it can be added harmlessly, I'll be thankful.

  • The property name accessed in runtime.js has to exactly match the property name in edittime.js. I noticed you have

    "Hex output format" in edittime.js and

    "Hexadecimal output format" in runtime.js,

    so at runtime you'll get a "property does not exist"/"property is undefined" error. If you change them to match does that fix it?

  • (Also, you can close the project and reopen and javascript files will be refreshed, it's a bit quicker than a full reload. Alternatively I made a registry key you can set:

    HKEY_CURRENT_USER\Software\Scirra\Construct2\html5 - add a new DWORD value 'devmode' (without quotes) - set its value to 1.

    Once that's set the scripts should be reloaded each time you hit run.)

  • The property name accessed in runtime.js has to exactly match the property name in edittime.js. I noticed you have

    "Hex output format" in edittime.js and

    "Hexadecimal output format" in runtime.js,

    so at runtime you'll get a "property does not exist"/"property is undefined" error. If you change them to match does that fix it?

    No it doesn't. The name change was a test I didn't finished, as I was wondering if maybe the length of the properties entered in play.

    I just tried with "Hex output format" for both, and still "this.properties is undefined Line 50". It's the whole properties array which is absent, not that single property.

    EDIT: I even tried "Hexoutput" as name of the property and it still didn't work.

    So it's not a length thing. I'll keep on looking.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oops, on further inspection it looks like an oversight in the SDK. 'singleglobal' objects can't have properties right now. You'll have to work around it with actions to set the settings.

    BTW I think MD5 is better described as a hash than encryption - I think encryption is supposed to be reversible.

  • BTW I think MD5 is better described as a hash than encryption - I think encryption is supposed to be reversible.

    Yes, please call this Hash as it is easily reversible. You don't want to give folks the wrong idea about the plugin's purpose. The goal of the hash algorithm (MD5) is to verify that the data hasn't been changed.

    Also, why not do SHA-1 if you are going to do a cryptographic hash algorithm.. MD5 has already been broken. <img src="smileys/smiley19.gif" border="0" align="middle" />

  • Oops, on further inspection it looks like an oversight in the SDK. 'singleglobal' objects can't have properties right now. You'll have to work around it with actions to set the settings.

    As those properties are not vital to the user at this stade of the plugin, I'll comment the lines refering to the properties (as it seems to me the code should work once the properties are part of the 'singleglobal' flaged objects.)

    I'll be uncommenting them when the changelog of a future build will indicate me to ;)

    BTW I think MD5 is better described as a hash than encryption - I think encryption is supposed to be reversible.

    You're right, thanks for the notice.

    JS is a fun language to work with, and the design of C2's extensions make them quite forward/"simple" to make. (cheers on the smart comments)

    It's thrilling.

    Yes, please call this Hash as it is easily reversible. You don't want to give folks the wrong idea about the plugin's purpose. The goal of the hash algorithm (MD5) is to verify that the data hasn't been changed.

    Also, why not do SHA-1 if you are going to do a cryptographic hash algorithm.. MD5 has already been broken. <img src="smileys/smiley19.gif" border="0" align="middle" />

    Category name changed to Hash, and reference to cryptography removed.

    I intend to implement SHA-1 and SHA-256 in the same plugin. I'll first have to get the md5 different outputs to correctly work and then implement the other.

    It should end as a multi-algorithms Hash plugin.

  • I intend to implement SHA-1 and SHA-256 in the same plugin. I'll first have to get the md5 different outputs to correctly work and then implement the other.

    It should end as a multi-algorithms Hash plugin.

    Just a heads up: the plugin ID in edittime.js GetPluginSettings() is currently "MD5". You can change all the other settings at any time, but the ID is the string C2 uses to identify your plugin. If you change the ID from "MD5" to something else, all existing projects using the plugin will no longer load, since C2 will consider it a different plugin.

    Basically, try to choose the correct ID string when starting a plugin, and then never change it, or you might end up breaking lots of projects. Since the only public version is broken, I guess now is a good time to set it to "Hash" or whatever :)

  • Please close this thread.

    The release topic is here -> http://www.scirra.com/forum/plugincb-hash-md5-sha1-and-sha256_topic43824_post274143.html

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)