Jump to content


Photo

SHA-2 (SHA-256) calculation from file


  • Please log in to reply
12 replies to this topic

#1 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 27 July 2012 - 12:22 AM

I quickly compiled this to a dll on request (copyright is all theirs, read their license).

It allows you to calculate the 32-Byte (256 Bit) SHA-2 hash of a file.

I included an example that shows how to convert the raw bytes to hex characters. Requires GM DLL.
Verify the results with e.g. http://hash.online-c...ha256-generator
Be sure to only use the hex string version of the hash (output second in the demo) when comparing and saving to a file, as the raw bytes are not well understood as text.

I hope you'll find it useful.
 

Download GM Sha2, including source files and example
 


Edited by Master Xilo, 23 August 2015 - 02:05 PM.

  • 2

#2 Jobo

Jobo

    Second-Scum-Of-The-Earth

  • YoYo Games Staff
  • 3000 posts
  • Version:GM:Studio

Posted 27 July 2012 - 12:28 AM

GM:Studio now supports SHA-1 encryption through GameMaker Language (GML) so I highly doubt your efforts will be as appreciated as they perhaps should...
  • 0

My posts are my own views and opinions... Unless they are yours too, in which case I think you're a very intelligent and handsome individual (I think you are anyway!)


#3 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 27 July 2012 - 11:50 AM

I wrapped this up in 15 min so there's not much effort. Also, this is SHA-2 (for which there are no known collisions, different from SHA-1), and it works for any GM version (that supports dlls).

Edited by Master Xilo, 27 July 2012 - 11:52 AM.

  • 0

#4 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 27 July 2012 - 12:19 PM

GM:Studio now supports SHA-1 encryption through GameMaker Language (GML) so I highly doubt your efforts will be as appreciated as they perhaps should...

You don't know what your talking about. Read wikipedia. SHA-1 has security flaws. That's why SHA-2 was adopted. So till GML supports that natively, this is the best kid on the block. :biggrin: Kudos master xilo. Will check and give feedback. Wait, moreover, this will be useful to thoose using lower versions of GM.

EDIT: the editable game maker file is in gm8 not gmk. I need a gmk compatible version, please.

Edited by SenJe0, 27 July 2012 - 12:33 PM.

  • 0
When I finish University, I would like to work for a BIG software Company like;SENJEN COMPANY. I'm obsessed with them! Period!

#5 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 25708 posts
  • Version:GM:Studio

Posted 27 July 2012 - 12:35 PM

GM:Studio now supports SHA-1 encryption through GameMaker Language (GML) so I highly doubt your efforts will be as appreciated as they perhaps should...

You don't know what your talking about. Read wikipedia. SHA-1 has security flaws. That's why SHA-2 was adopted. So till GML supports GML that natively, this is the best kid on the block. :biggrin: Kudos master xilo. Will check and give feedback. Wait, moreover, this will be useful to thoose using lower versions of GM.

EDIT: the editable game maker file is in gm8 not gmk. I need a gmk compatible version, please.


I think that a probability of a theoretical attack of (251) is sufficiently low that most people really don't care... and GM:S has it simply because it IS considered a standard for many applications and protocols.

On-topic, good job with this!
  • 0

U1FVsm3.png

40799.png


#6 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 27 July 2012 - 12:50 PM

I pasted it in Game maker and I saw this error
___________________________________________
ERROR in
action number 1
of Create Event
for object object0:

sha2 (SHA-256) of test.txt (as bytes): "-&ejSR2I6

___________________________________________
ERROR in
action number 1
of Create Event
for object object0:

sha2 (SHA-256) of test.txt (as hex string) - verify with http://hash.online-convert.com/sha256-generator: 
b08022d315cf1eb12d2665bded0e6af40653c0a0be975232fb49bcbd021cfc36

  • 0
When I finish University, I would like to work for a BIG software Company like;SENJEN COMPANY. I'm obsessed with them! Period!

#7 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 27 July 2012 - 12:52 PM

Lol, sory don't worry. I realised that in the code you had used show_error function. Everything works perfectly. I downloaded gm8.1 and converted the script myself. Thank you soo much. +1.
  • 0
When I finish University, I would like to work for a BIG software Company like;SENJEN COMPANY. I'm obsessed with them! Period!

#8 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 27 July 2012 - 12:56 PM

Yeah show_message wouldn't print all the characters and you couldn't copy paste the result.
  • 0

#9 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 28 July 2012 - 08:25 PM

I wish I could calclate sha-2 of string
  • 0
When I finish University, I would like to work for a BIG software Company like;SENJEN COMPANY. I'm obsessed with them! Period!

#10 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 28 July 2012 - 08:46 PM

Write the string to a file or extend the dll to export that function as well. You should be able to do that by yourself. Look at my code.
  • 0

#11 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 30 July 2012 - 09:38 PM

Write the string to a file or extend the dll to export that function as well. You should be able to do that by yourself. Look at my code.

Thanks man. Works like a charm.
  • 0
When I finish University, I would like to work for a BIG software Company like;SENJEN COMPANY. I'm obsessed with them! Period!

#12 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 194 posts
  • Version:GM:Studio

Posted 09 August 2012 - 08:40 AM

It's very good. But I do not have gm81. :sad:

Edit : Oh, my God. "GM DLL Extension" could work on only gm81. (not gm8)

Edited by wnsrn3436, 09 August 2012 - 09:03 AM.

  • 0

#13 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 396 posts
  • Version:GM8

Posted 09 August 2012 - 09:21 AM

You can get it to work with gm8, ask SenJe0.
  • 0