Jump to content




PHP - html - javascript



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

#1 Goof

  • Members
  • 751 posts

Posted 09 May 2013 - 03:36 AM

Hello.

i'm trying to make a webpage, which has a 128 bit long string. but every X seconds that string, has to change, (the first string may never appear again, if used)
like a random string generator

but im quite lost, finding out, how..

btw. im using this to my AdvLock, program, ( new update )


Thanks in Advance :D

#2 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

Posted 09 May 2013 - 04:51 AM

This might help. It's pretty easy to use! :3

#3 Goof

  • Members
  • 751 posts

Posted 09 May 2013 - 05:20 AM

ehhm.. how do i make it myself?
im making a website which displays a random 64 bit hexadecimal, and then changes that whole 64 bit string into another random... but the strings may NEVER appear again, if used before.
but what i wanted is just an example on how to do it with my own website...

But thanks :D

Any help, please?

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 09 May 2013 - 07:27 AM

You know that this is a forum for ComputerCraft, which is Lua, right?

#5 GravityScore

  • Members
  • 796 posts
  • LocationLand of Meh

Posted 09 May 2013 - 07:49 AM

I'll answer this even though this isn't CC related:

Simplest way is to use PHP and hash a random number (using SHA-1, because that will generate a hexadecimal string 128 bits long - 16 characters). Also, if this string is requested from within CC, it's probably easier just to change it each time the page is loaded, unless you want to write something that remembers the current string, and will change it if it's been longer than X seconds. PHP to generate the random string:
echo hash("sha1", rand(0, 2147483647));

2147483647 is the largest possible integer in PHP for a 32 bit system.

#6 Goof

  • Members
  • 751 posts

Posted 09 May 2013 - 08:09 AM

well that doesnt show me anything, when testing..
btw. how do i then get the random string, to the computer.. (the computer reads the whole code for the website, and cant see the random string?)
EDIT: nevermind.. forgot to add <?php
EDIT2: nevermind about the "btw how do i ..."

#7 Goof

  • Members
  • 751 posts

Posted 09 May 2013 - 08:35 AM

View Posttheoriginalbit, on 09 May 2013 - 07:27 AM, said:

You know that this is a forum for ComputerCraft, which is Lua, right?

Yes.. but this IS computercraft related.. i want to use it in my program..


But.. now i've seen that this: doesnt work properly.. i want it to delete everything from the table from the website, and only store the 128 bit string..
as i said.. this doesnt work:



x = http.get("http://advlock.webuda.com/index.php")
red = tostring(x.readAll())
print(red)
for k,v in string.gmatch(red, "(%w+)<header>(%w+)") do
	print(k,v)
	sleep(1)
end		

EDIT: ehm, btw.. the random hexadecimal generator.. would that at anytime be equal to an existing hexadecimal?
like would the generator at some point generate the same password, two times?

#8 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 09 May 2013 - 04:04 PM

Moved to General.

#9 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 09 May 2013 - 04:35 PM

I would use something like this, however, I cant seem to get the array_search to get working properly :S
Im kind of new to PHP and this is just something I scrapped together. I hoped I at least pushed you in the right direction :)

Spoiler


#10 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 09 May 2013 - 04:43 PM

View PostMikk809h, on 09 May 2013 - 08:35 AM, said:

View Posttheoriginalbit, on 09 May 2013 - 07:27 AM, said:

You know that this is a forum for ComputerCraft, which is Lua, right?

Yes.. but this IS computercraft related.. i want to use it in my program..


But.. now i've seen that this: doesnt work properly.. i want it to delete everything from the table from the website, and only store the 128 bit string..
as i said.. this doesnt work:



x = http.get("http://advlock.webuda.com/index.php")
red = tostring(x.readAll())
print(red)
for k,v in string.gmatch(red, "(%w+)<header>(%w+)") do
	print(k,v)
	sleep(1)
end		

EDIT: ehm, btw.. the random hexadecimal generator.. would that at anytime be equal to an existing hexadecimal?
like would the generator at some point generate the same password, two times?
In the output (the source you can see in a webbrowser) of an php script isn't a tag unless you printed it out. So, your program can't find the head tag :)

#11 Goof

  • Members
  • 751 posts

Posted 09 May 2013 - 05:32 PM

Well Thanks.. everything works now.. :D but i have a new question:

in my program, then it
http.get("randomGenerator name")
. but.. then i want the cc terminal to:
http.post("website, with mysql database")
so the serial key(the random string) would be store inside that mysql database.
how do i then make a new website, which saves the serial key, sended and thenstore it to the db?

Thanks

#12 Tiin57

    Java Lunatic

  • Members
  • 1,412 posts
  • LocationIndiana, United States

Posted 11 May 2013 - 06:54 AM

If I understand your second question correctly, the answer is Google + basic comprehension skills.

#13 Imque

  • Members
  • 134 posts

Posted 13 May 2013 - 06:52 AM

Use the PHP $_POST to get data from the request but use http.request not http.post or http.get

#14 GravityScore

  • Members
  • 796 posts
  • LocationLand of Meh

Posted 13 May 2013 - 06:57 AM

View PostImque, on 13 May 2013 - 06:52 AM, said:

Use the PHP $_POST to get data from the request but use http.request not http.post or http.get

http.post and http.get just wrap the http.request function (they call it). It'll make no difference (apart from the way the data is returned) calling http.request over http.post or http.get.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users