Jump to content




Need help with SHA hashing.

lua help utility

  • You cannot reply to this topic
8 replies to this topic

#1 Creator

    Mad Dash Victor

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

Posted 02 February 2015 - 07:45 PM

Hi guys,

I was searching the internet for a hashing program and found this program:

Spoiler

So when I start lua in the shell and then type os.loadAPI("SHA") and then type sha.sha1("hi") it says that there was an error on line 27: attempt to call nil. I have no idea why it is happening. Any help would be appreciated.

Thanks

#2 InDieTasten

  • Members
  • 357 posts
  • LocationGermany

Posted 02 February 2015 - 08:10 PM

We cannot know what line 27 is, because the spacing was removed from your code-section. please insert the code by hand between the code tags to avoid manipulation by the forums

Or just upload to pastebin, which gets rid of all problems, because the forums code snippets s*ck

#3 Creator

    Mad Dash Victor

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

Posted 02 February 2015 - 08:17 PM

View PostInDieTasten, on 02 February 2015 - 08:10 PM, said:

We cannot know what line 27 is, because the spacing was removed from your code-section. please insert the code by hand between the code tags to avoid manipulation by the forums

Or just upload to pastebin, which gets rid of all problems, because the forums code snippets s*ck

Sorry, line 27 is the line in the middle of this piece of code:

local function LeftRotate(val, nr)
  return shl(val, nr) + shr(val, 32 - nr)
end

Edited by creator, 02 February 2015 - 08:17 PM.


#4 InDieTasten

  • Members
  • 357 posts
  • LocationGermany

Posted 02 February 2015 - 08:25 PM

View Postcreator, on 02 February 2015 - 08:17 PM, said:

View PostInDieTasten, on 02 February 2015 - 08:10 PM, said:

We cannot know what line 27 is, because the spacing was removed from your code-section. please insert the code by hand between the code tags to avoid manipulation by the forums

Or just upload to pastebin, which gets rid of all problems, because the forums code snippets s*ck

Sorry, line 27 is the line in the middle of this piece of code:

local function LeftRotate(val, nr)
  return shl(val, nr) + shr(val, 32 - nr)
end
You/the API are/is calling shl and shr, which are set to bit.lshift and bit.rshift. it seems these functions are not available in your environment

Here you can see they are not available in the names given in the api, but you can change them to blshift and brshift to fix that part. I wouldn't be surprised, if there are lots of other problems approaching you afterwards

#5 Creator

    Mad Dash Victor

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

Posted 02 February 2015 - 08:29 PM

View PostInDieTasten, on 02 February 2015 - 08:25 PM, said:

View Postcreator, on 02 February 2015 - 08:17 PM, said:

View PostInDieTasten, on 02 February 2015 - 08:10 PM, said:

We cannot know what line 27 is, because the spacing was removed from your code-section. please insert the code by hand between the code tags to avoid manipulation by the forums

Or just upload to pastebin, which gets rid of all problems, because the forums code snippets s*ck

Sorry, line 27 is the line in the middle of this piece of code:

local function LeftRotate(val, nr)
  return shl(val, nr) + shr(val, 32 - nr)
end
You/the API are/is calling shl and shr, which are set to bit.lshift and bit.rshift. it seems these functions are not available in your environment

Here you can see they are not available in the names given in the api, but you can change them to blshift and brshift to fix that part. I wouldn't be surprised, if there are lots of other problems approaching you afterwards

You are so right. It now says java exception from thrown.

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 02 February 2015 - 09:28 PM

Intersperse print statements throughout your script. By checking which ones fire before the "exception" error, placing more in that area of the script and so on, you should be able to narrow it down to a particular line.

#7 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 03 February 2015 - 11:09 AM

I don't get why you don't use the SHA256 hashing algorithm already implemented in lua and works in computercraft because I use it? It's a lot easier!:D if you want it just tell me, will post it underneath

#8 Anavrins

  • Members
  • 775 posts

Posted 03 February 2015 - 12:50 PM

GravityScore's SHA256 here
Should work without modification, and is way more secure than SHA1 or MD5.

#9 Creator

    Mad Dash Victor

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

Posted 03 February 2015 - 03:18 PM

View PostDannySMc, on 03 February 2015 - 11:09 AM, said:

I don't get why you don't use the SHA256 hashing algorithm already implemented in lua and works in computercraft because I use it? It's a lot easier! :D if you want it just tell me, will post it underneath

Thanks man.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users