Jump to content




SHA-256 in Pure Lua

utility lua api

66 replies to this topic

#21 Left

  • Members
  • 88 posts

Posted 22 March 2013 - 10:32 PM

Thanks! Also do I have permission to use it in a little side project. If you don't reply I'll take it as a yes. It saves you the typing. xD

#22 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 22 March 2013 - 10:35 PM

View PostLinearus, on 22 March 2013 - 10:32 PM, said:

Thanks! Also do I have permission to use it in a little side project. If you don't reply I'll take it as a yes. It saves you the typing. xD

View PostGravityScore, on 05 January 2013 - 09:38 AM, said:

In regards to copyright: both of these sources allow the free use of the code in them - they do not require you to include credits or licenses (to be honest, they aren't very clear about who exactly wrote them...).


#23 GravityScore

  • Members
  • 796 posts
  • LocationLand of Meh

Posted 23 March 2013 - 12:08 AM

View PostTheOriginalBIT, on 22 March 2013 - 10:35 PM, said:

View PostLinearus, on 22 March 2013 - 10:32 PM, said:

Thanks! Also do I have permission to use it in a little side project. If you don't reply I'll take it as a yes. It saves you the typing. xD

View PostGravityScore, on 05 January 2013 - 09:38 AM, said:

In regards to copyright: both of these sources allow the free use of the code in them - they do not require you to include credits or licenses (to be honest, they aren't very clear about who exactly wrote them...).

I was going to point this out, but thought nahhh. Linearus: you can use this and other smaller utilities/APIs by me freely without having to ask. If you want to use a program, I wouldn't mind you asking, but it's almost a guaranteed yes.

#24 GravityScore

  • Members
  • 796 posts
  • LocationLand of Meh

Posted 29 March 2013 - 03:38 AM

I've updated the SHA-256 to fix quite a big bug, and it should now print out exactly what is printed out by PHP and JavaScript. Hope this can make a few people's lives easier!

Beware when updating your program: any stored passwords that were generated using the previous version will be redundant, and will not be comparable with this new version.

#25 Azhf

  • Members
  • 180 posts
  • LocationMurrika

Posted 29 March 2013 - 03:40 AM

Awesome man :D

#26 Shazz

  • Members
  • 175 posts

Posted 18 May 2013 - 11:55 PM

This might be a late post.
The implementation doesn't work for strings with length 55.
If the string's length is 55 then the hashing breaks.
Tested multiple times against PHP's hash function.

#27 johnnic

  • Members
  • 50 posts
  • LocationSomewhere in ****** County, *******

Posted 24 June 2013 - 03:42 PM

Would you mind if I used this function in my OS? I am looking for a secure way to store the passwords, and have the OS as a program ran from shell.

#28 GravityScore

  • Members
  • 796 posts
  • LocationLand of Meh

Posted 24 June 2013 - 05:52 PM

Sure, go ahead!

#29 oxygencraft

  • Members
  • 38 posts

Posted 18 November 2015 - 06:59 AM

How do i use this thing?

#30 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 18 November 2015 - 01:21 PM

View Postoxygencraft, on 18 November 2015 - 06:59 AM, said:

How do i use this thing?

Put the code at the top of your program, then use the sha256 function to make hashes.

#31 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 18 November 2015 - 02:03 PM

os.loadAPI("sha")
sha.sha256("my string")


#32 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 18 November 2015 - 02:24 PM

View PostCreator, on 18 November 2015 - 02:03 PM, said:

os.loadAPI("sha")
sha.sha256("my string")
Nope. This "snippet" has to be included in your own code and can't be loaded as API.

#33 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 18 November 2015 - 02:43 PM

Yes, exactly. This is your code.

#34 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 18 November 2015 - 04:11 PM

View PostCreator, on 18 November 2015 - 02:43 PM, said:

Yes, exactly. This is your code.

You misunderstand. The code in the OP uses a local sha256 function, therefor when loaded as an API it will not be exposed and the code you posted will error with attempt to call nil.

#35 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 18 November 2015 - 04:15 PM

View PostKingofGamesYami, on 18 November 2015 - 04:11 PM, said:

View PostCreator, on 18 November 2015 - 02:43 PM, said:

Yes, exactly. This is your code.

You misunderstand. The code in the OP uses a local sha256 function, therefor when loaded as an API it will not be exposed and the code you posted will error with attempt to call nil.
I use this API with sha256 and there has never been a problem.

#36 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 18 November 2015 - 04:26 PM

The point is that you cannot possibly be using this code in the way you suggest without modifying it. All functions in the "API" are declared as local, so nothing would be exposed for use if this was loaded with os.loadAPI.

#37 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 18 November 2015 - 04:47 PM

In the paste it is local. What is strange is that I have that API and it is not local nor do I remember unlocalizing it. Well, to make it short, remove the local before sha256 is declared.

#38 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 18 November 2015 - 04:53 PM

View PostCreator, on 18 November 2015 - 04:47 PM, said:

In the paste it is local. What is strange is that I have that API and it is not local nor do I remember unlocalizing it. Well, to make it short, remove the local before sha256 is declared.

IMO it would be better to add these functions to your own script because otherwise some malware could modify the hash function so it returns always the same "hash" which would be a big security hole.

#39 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 19 November 2015 - 06:30 PM

View PostH4X0RZ, on 18 November 2015 - 04:53 PM, said:

IMO it would be better to add these functions to your own script because otherwise some malware could modify the hash function so it returns always the same "hash" which would be a big security hole.
Well that only applies if someone has access to the computer, and in my experience there aren't that many sophisticated and advanced viruses in CC, so I'd say that you probably don't have to worry about that.
But it's definitely something to consider ofcourse, but it's still easier to keep it as a separate API IMO.

#40 Wojbie

  • Members
  • 631 posts
  • LocationKinda lost

Posted 19 November 2015 - 10:19 PM

Personally i just changed it to this form: http://pastebin.com/UsT5BtHa and stick it near top of my program. Less readable but fits in 2 lines. Inside cc editor its basically invisible and in outside editors you can just hide that line easily and fast with one/two clicks..





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users