• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=Goz3rr;46294318]PHP's crypt() makes a hash, it's not encryption because it can't be reversed. I'm not sure what exactly you're trying to do here but it seems you're way overcomplicating. Just hash the entire password at once and use a salt[/QUOTE] I just want to make it work so every day the password ends up different, but only server knows how to read it.
[QUOTE=KinderBueno;46294395]I just want to make it work so every day the password ends up different, but only server knows how to read it.[/QUOTE] server should only compare with unrecoverable hash. You or the server should never be able to see what the password is.
What are some generic ways to slow a game down to a maximum benchmark?
[QUOTE=KinderBueno;46294395]I just want to make it work so every day the password ends up different, but only server knows how to read it.[/QUOTE] What do you need a daily password for? [editline]21st October 2014[/editline] Also, posting secrets like a password scheme on a public forum probably isn't the best idea
[QUOTE=DrTaxi;46297200]What do you need a daily password for? [editline]21st October 2014[/editline] Also, posting secrets like a password scheme on a public forum probably isn't the best idea[/QUOTE] I ended up just using Crypt() because I got pissed off. Spent whole day trying to parse variables from PHP form to Node.js and Express. Kinda worked but now it acts fucked up, basically day wasted. I know it belongs more to Web Dev section but just in case: Anyone know how can I: Login on index.php using PHP form, check mysql database etc.. Then form action goes to: website.com:3000 (node/sockets etc..) and how to parse those POST vars? Just in case anyone knows?
[QUOTE=KinderBueno;46298868]I ended up just using Crypt() because I got pissed off. Spent whole day trying to parse variables from PHP form to Node.js and Express. Kinda worked but now it acts fucked up, basically day wasted. I know it belongs more to Web Dev section but just in case: Anyone know how can I: Login on index.php using PHP form, check mysql database etc.. Then form action goes to: website.com:3000 (node/sockets etc..) and how to parse those POST vars? Just in case anyone knows?[/QUOTE] Again, why would you bother doing it in two seperate steps if you could just do it in one. nodejs can connect to mysql just fine. If you really wanted to do it this way use php to proxy the request instead of having to mess around with redirecting the user
Is the a comprehensive SDL library reference? I learn best just by looking at References and examples, rathr than tutorials.
[QUOTE=Goz3rr;46300517]Again, why would you bother doing it in two seperate steps if you could just do it in one. nodejs can connect to mysql just fine. If you really wanted to do it this way use php to proxy the request instead of having to mess around with redirecting the user[/QUOTE] Well I used PHP login because I am not sure how to make it so when user visits: website.com it goes to website.com:3000 Also I don't know how to restrict access directly to website.com:3000 if user is not logged in. Right now if someone goes to website.com:3000 directly without logging in - it crashes server.
So I was doing a little playing around with filestreams, and I wrote this: [code] #include <stdio.h> int main(){ int n; FILE * pFile; char buffer [30]; pFile = fopen ("myfile.txt","w+"); for ( n='A' ; n<='Z' ; n++){ fputc ( n, pFile); } rewind(pFile); rewind (pFile); for(int i=1;i<27;i++){ fread (buffer,1,i,pFile); printf("%s\n",buffer); rewind(pFile); } fclose(pFile); buffer[27]='\0'; puts (buffer); return 0; } [/code] to which the output was: [code] collin@collin-HP-15-Notebook-PC:~/Documents$ ./readfile A AB ABC ABCD ABCDE ABCDEF ABCDEFG ABCDEFGH@ ABCDEFGH@ ABCDEFGHIJ@ ABCDEFGHIJK ABCDEFGHIJKL ABCDEFGHIJKLM ABCDEFGHIJKLMN ABCDEFGHIJKLMNO ABCDEFGHIJKLMNOP ABCDEFGHIJKLMNOPQ&#65533;"&#65533; ABCDEFGHIJKLMNOPQR"&#65533; ABCDEFGHIJKLMNOPQRS&#65533; ABCDEFGHIJKLMNOPQRST&#65533; ABCDEFGHIJKLMNOPQRSTU ABCDEFGHIJKLMNOPQRSTUV ABCDEFGHIJKLMNOPQRSTUVW ABCDEFGHIJKLMNOPQRSTUVWX ABCDEFGHIJKLMNOPQRSTUVWXY ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ [/code] Why is it that around the I and J area, and the Q-V area, things start fucking up? The thing is, whenever I run the program, the fuckupedness changes every time, so I get different random characters around the H-J and Q-V marks
[QUOTE=proboardslol;46301584]So I was doing a little playing around with filestreams, and I wrote this: to which the output was: Why is it that around the I and J area, and the Q-V area, things start fucking up? The thing is, whenever I run the program, the fuckupedness changes every time, so I get different random characters around the H-J and Q-V marks[/QUOTE] Buffer is uninitialized. It's not filled with zeroes initially. [code]fread (buffer,1,i,pFile);[/code] You read one character into the buffer. The contents of the buffer after that character remain unknown. [code]printf("%s\n",buffer);[/code] This function will print contents from the buffer until it encounters a null character. There is no guarantee that a null character exists in the buffer.
[QUOTE=ThePuska;46301622]Buffer is uninitialized. It's not filled with zeroes initially. [code]fread (buffer,1,i,pFile);[/code] You read one character into the buffer. The contents of the buffer after that character remain unknown. [code]printf("%s\n",buffer);[/code] This function will print contents from the buffer until it encounters a null character. There is no guarantee that a null character exists in the buffer.[/QUOTE] I added buffer[i+1]='\0' to the for loop. It fixed it, but is this a good solution going forward? Also what is it exactly doing? is it reading the contents of some other random file and interpretting them as a string?
[QUOTE=proboardslol;46301792]I added buffer[i+1]='\0' to the for loop. It fixed it, but is this a good solution going forward?[/QUOTE] Yes [QUOTE]Also what is it exactly doing? is it reading the contents of some other random file and interpretting them as a string?[/QUOTE] It's reading whatever previously resided where the buffer now is. Since the buffer is located on the stack, it's likely that the uninitialized buffer contains pointers and some local variables of functions that executed prior to yours.
Hey, quick C++ beginner question hopefully someone can help me with. I have a project for class to calculate inflation where we have to have 3 functions, an input function, a calculation function, and an output function, and no global variables allowed. Where I am stuck is how to somehow use the inputs I get from the user in my input function to work inside my calculation function. I would post code but it is barely anything at all and I don't want people to think I am asking to have someone do my homework, because I really can't continue on without figuring out this issue. Thanks! Quick Edit: Would I be able to somehow use the input variables as like a temporary thing, and then use return variable; to somehow allow them to be used by the calculation function?
output(calculation(input()));
[QUOTE=WeltEnSTurm;46302922]output(calculation(input()));[/QUOTE] Hey, thanks for the tip, I tried doing that but it still doesn't work how I need it to. I need to use the values that the user inputs into the input function in the calculations function. So there are 3 values in the input function, and I need to somehow use those in the math portion of the calculation function.
[QUOTE=Gubbygub;46303043]Hey, thanks for the tip, I tried doing that but it still doesn't work how I need it to. I need to use the values that the user inputs into the input function in the calculations function. So there are 3 values in the input function, and I need to somehow use those in the math portion of the calculation function.[/QUOTE] Return array of whatever the input type is in the input function and accept array of whatever the input type is in the calculation function?
[QUOTE=cartman300;46303143]Return array of whatever the input type is in the input function and accept array of whatever the input type is in the calculation function?[/QUOTE] That's what a lot of the lessons online I am finding are saying to do, but the problem is we haven't got to arrays yet in our C++ class and I am unsure how to use them correctly, and I don't know how the professor would like it if I used something that he hasn't taught yet. So far the previous chapters have been able to be completed with just what was learned in that chapter plus the previous ones, so there should be a way to do this one without arrays. Thank you for the tip though, if I can't figure it out before the due date I will try to learn about arrays and use it in this project.
[QUOTE=Gubbygub;46303229]That's what a lot of the lessons online I am finding are saying to do, but the problem is we haven't got to arrays yet in our C++ class and I am unsure how to use them correctly, and I don't know how the professor would like it if I used something that he hasn't taught yet. So far the previous chapters have been able to be completed with just what was learned in that chapter plus the previous ones, so there should be a way to do this one without arrays. Thank you for the tip though, if I can't figure it out before the due date I will try to learn about arrays and use it in this project.[/QUOTE] 3 inputs you say? [code]output(calculation(input(), input(), input()));[/code]
[QUOTE=cartman300;46303260]3 inputs you say? [code]output(calculation(input(), input(), input()));[/code][/QUOTE] I kind of get what you are going for, but what I really need to know is if there is some way to use a variable from one function in another function, without declaring a global variable before main(). For example, I have a variable, current, in my input function. The user will be prompted to enter a value for current. I need to use this value in the calculation function. The problem says we are not allowed global variables though, so I don't know how I can use this variable. I'm really sorry if it seems simple for you, and I am being an idiot, but I just started learning programming this semester, so I am still learning the basics. Also, I am probably phrasing this question in an awful way, and I apologize. I could post the question if it would help someone understand whats going on, but I don't want to just have someone do this project for me.
[QUOTE=Gubbygub;46303385]I kind of get what you are going for, but what I really need to know is if there is some way to use a variable from one function in another function, without declaring a global variable before main(). For example, I have a variable, current, in my input function. The user will be prompted to enter a value for current. I need to use this value in the calculation function. The problem says we are not allowed global variables though, so I don't know how I can use this variable. I'm really sorry if it seems simple for you, and I am being an idiot, but I just started learning programming this semester, so I am still learning the basics. Also, I am probably phrasing this question in an awful way, and I apologize. I could post the question if it would help someone understand whats going on, but I don't want to just have someone do this project for me.[/QUOTE] Did you learn pointers? [code] int main() { intype A; intype B; input(&A, &B); output(calculate(&A, &B)); } [/code] [editline]22nd October 2014[/editline] And no you can't use variables in function A from function B without pointers or arrays. [editline]22nd October 2014[/editline] Or directly returning these variables.
[QUOTE=cartman300;46303433]Did you learn pointers? [code] int main() { intype A; intype B; input(&A, &B); output(calculate(&A, &B)); } [/code] [editline]22nd October 2014[/editline] And no you can't use variables in function A from function B without pointers or arrays. [editline]22nd October 2014[/editline] Or directly returning these variables.[/QUOTE] We didn't learn pointers yet, but by returning variables do you mean like at the end of one of the functions I would do return variable; and then I can use it elsewhere?
[QUOTE=Gubbygub;46304367]We didn't learn pointers yet, but by returning variables do you mean like at the end of one of the functions I would do return variable; and then I can use it elsewhere?[/QUOTE] Basically, you could make the input function accept a string prompt, print that prompt in function, parse the input and then return that input, it would first evaluate inner most calls and return that to calculation. I really don't see a problem in this: [code] output(calculation(input("Input A:"), input("Input B:"), input("Input C:"))); [/code] But if you don't want to do it in such way then just post the question because else i can't help.
[QUOTE=Gubbygub;46304367]We didn't learn pointers yet, but by returning variables do you mean like at the end of one of the functions I would do return variable; and then I can use it elsewhere?[/QUOTE] [code] int input() { return *input variable here* } int main() { int inputresult = input(); } [/code] Make sure to make the function of the same type of variable you're returning, so it'd be float input() {} when working with floats.
[QUOTE=Gubbygub;46304367]We didn't learn pointers yet, but by returning variables do you mean like at the end of one of the functions I would do return variable; and then I can use it elsewhere?[/QUOTE] I see what they were getting at with forbidding global variables, they want to teach you how to use return values. You can assign return values to variables like this: [code] int main(){ float varA = input(); float varB = input(); float varC = input(); float result = calculate(varA, varB, varC); // pass all three of them to calculate and assign return value to 'result' output(result); return 0; }[/code]
Maybe you should post the exact specification. It'd be easier to know exactly what you're trying to do
[QUOTE=FalconKrunch;46305073][code] int input() { return *input variable here* } int main() { int inputresult = input(); } [/code] Make sure to make the function of the same type of variable you're returning, so it'd be float input() {} when working with floats.[/QUOTE] I think this is exactly what I was going for! I am going to try it out and see if it works! Thank you to everyone by the way, awesome to see everyone try and help out. Edit: Yes that worked! Now I just have to figure out where I fucked up the rest of it. Thanks a bunch everyone! Oh and here's the question from the book (#24) if you guys wanted to look at it, and maybe there are some other new C++ people that need some practice problems or something. [t]http://i.imgur.com/e1Uqbfr.jpg[/t]
hey i'm writing a little thing that reads a file for email addresses, identifies them, then writes them to another file i can get all the emails written the output file just fine, but i also need to remove the trailing commas, and only the trailing commas, from the email addresses i'm not really sure how i can do that though so some help would be awesome so far i've got this, written in c++ [CODE] #include <iostream> #include <string> #include <fstream> using namespace std; int main() { ifstream inMails; // Declares the input file ofstream outMails; // Declares the ouput file string email; // Declares the variable for the emails to be written to int at; // Used to identify a string as an email address inMails.open("mail.dat"); // Prepares the input file to be read outMails.open("addresses.dat"); // Prepares the output file to be written // Searches the input file for email addresses then outputs them to // the output file while (!inMails.eof()) { inMails >> email; at = email.find('@'); if (at > 0) outMails << email << endl; } return 0; } [/CODE]
[QUOTE=Gubbygub;46305570]I think this is exactly what I was going for! I am going to try it out and see if it works! Thank you to everyone by the way, awesome to see everyone try and help out. Edit: Yes that worked! Now I just have to figure out where I fucked up the rest of it. Thanks a bunch everyone! Oh and here's the question from the book (#24) if you guys wanted to look at it, and maybe there are some other new C++ people that need some practice problems or something. [t]http://i.imgur.com/e1Uqbfr.jpg[/t][/QUOTE] [code] void input(){ int priceYearOne; int priceYearTwo; scanf("%d",&priceYearOne); scanf("%d",&priceYearTwo); output(calculate(priceYearOne,priceYearTwo)); } int calculate(int priceYearOne, int priceYearTwo){ return (priceYearTwo-priceYearOne)/priceYearOne; } void output(int result){ printf("Inflation Rate is: %d",result); }[/code] is this acceptable by your specification's standards? its in C
So I'm a sophomore CS major. I want to do a side project that might be just a little bit ambitious, but I really wanna do it. What I ask for is how should I go about it, what language should I program it in (I know intermediate+ java and intermediate python), where I can find resources on how I can do this (I don't really know what it's called) and if this would be too difficult for me. So I play a lot of Dota, Starcraft, and Chess and was thinking why don't I make my own inhouse program. I want to do this for Dota right now, and I want it so that there is a user-id/password system where it would record a person's elo. After logging in, the program would open up a gui with who's online and how many open lobbies, when a lobby is full, the system would try to sort the team by elo (still trying to figure out a formula for this) and then generate a random password for the lobby leader to create a lobby in dota. Then after the game, after 5 people have marked the result of the game (win/loss/draw), the system would calculate elo and then close the lobby. I don't care if there are already programs that do this, I just want to do this for experience and fun but something I can also ship out the door. Any thoughts?
Who makes android apps? How do I prevent my app from resetting randomly? For example, I have a toggle button that does tasks when enabled, I want this to work in the background as long as the process is running and button is on, but sometimes randomly when I got back to check on the app, the onCreate function is called and my button is disabled, even though the app was already running. It seems to reset when another process is created or deleted.
Sorry, you need to Log In to post a reply to this thread.