Jump to content

TedCopple

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

TedCopple's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Can anybody help me figure out why the xor functions are not matching perfectly? if I send my name encrypted to the server, the php script outputs it perfecty via its decryption. However if I send my name or a password containing numbers/letters, it botches it somehow. It will either remove a character, or duplicate characters.
  2. alright..still having issues. Using my xor func and the one you posted above. What happens is it works fine for some strings. However some strings it botches. One of the strings it skips a single character, and the other string it duplicates a few characters, another string it works perfectly fine.
  3. Sorry, my example my function was bad too. When using the function I actually it setup with a return. function dec($User){ for($i=0;$i<strlen($User);$i++) { $theuser = $User{$i} ^ "87"; return $theuser; } } $out = dec($user); -----> Outputs first letter only echo $out;
  4. Ok, you were right. This works. Wonder why my function didn't work though. for($i=0;$i<strlen($tobXORd);$i++) { $toxor .= $tobXORd{$i} ^ "87"; } echo $toxor; function dec($User){ for($i=0;$i<strlen($User);$i++) { $theuser = $User{$i} ^ "87"; echo $theuser; ---> Outputs entire encrypted string. } } $out = dec($user); -----> Outputs first letter only echo $out; I tried $theuser .= as well, the call to the function to fill $out only gives $out the first letter.
  5. One last thing, if I do this: for($i=0;$i<strlen($User);$i++) { $out = $User{$i} ^ "87"; echo $out; <------------ outputs the entire decrypted string. } echo $out; <------- Outputs only the last letter. Nevermind, put it in a func that echos it and now its working proper.
  6. Alright, thanks again for your efforts. Very helpful.
  7. The difference was the key(as you mentioned). I am using an int key in my C++ XOR func, I changed the key in the php script from 56 to 87 and now the results match up even though the key being used in C++ is 56. I suppose I will try to change to a string key in C++ and see if I can use the same exact key for both. What more information would you like? The original string was actually my name, I am making a simple login system in my C++ application, but I don't want to make it too easy for people to spoof login info, and when using HTTP wininet funcs in C++ the strings sent to the server are easily available in an HTTP packet sniffer. I just want to be able to do a simple XOR operation on my sent data strings when sending data out, convert the string back to normal in the php script, check the data against the db entries, re-XOR the data and send it back. Then un-XOR it again and check it against data in my C++ app. I posted the C++ code and the php func I am now using looks like this: OUTPUT = QLKYMK]JVYU] -> matches my C++ output exactly witch is using int key = 56 as the key. <? $toxor = 'itsausername'; //$out = ""; $key = '56'; for($i=0;$i<strlen($toxor);$i++) { $out = $toxor{$i} ^ "87"; echo $out; } ?>
  8. so far the function you posted isn't working. it only processes the first character, and it seems it was the same thing as mine did. I did a simple XOR in C++ on the capital letter "A" output = y Lowercase Y. in php these had the following effects: Output = t <? $toxor = 'A'; //$out = ""; $key = '56'; for($i=0;$i<strlen($toxor);$i++) { $out = $toxor{$i} ^ '56'; echo $out; } ?> output = * <? $toxor = 'A'; //$out = ""; $key = '56'; for($i=0;$i<strlen($toxor);$i++) { $out = $toxor{$i} ^ key; echo $out; } ?>
  9. Hey thanks alot, I will give it a look.
  10. I am trying to send a XOR encrypted string through C++ to a php script and then re-XOR it on the php side to get the original string, however the XOR func I have tried on the php side ouputs a different string then the C++ side does. XOR the string this in C++ output = LPQK XOR the string this in php output = A]\F I am using the same key for both sides. C++ key=56 void encfunc(char* input, int key) { int strLen = strlen(input); for(int i=0; i<strLen; i++) { input[i] = input[i] ^ key; } } php key=56 for($i=0;$i<strlen($User);$i++) { $outText .= $User{$i} ^ $key; }
  11. Alright thanks to the both of you for responses. Very helpful stuff. Also thanks for the little bit of SQL Injection prevention. Somebody mentioned something about that to me earlier today, and I was going to look into it, so thanks.
  12. Alright, wasn't quite sure how to summarize this in the title, but I want to: Check if a user status is "active" or not based on the UserName input. I have a table witch holds: VarChar Username Var CharPassWord int Active Ted TedsPW 1 something like the above(assuming it formatted correctly. In my php script I will want to input a variable for Username to check for: inputUN in this example would be "Ted". $UserNameToCheck = $_GET['inputUN']; Then I want to check for that UserName in the database, if it exists, I want pull the value for the "Active" field for just that UserName and echo it. Thanks for any help.
  13. Hey, thanks a lot for that. Very informative for me. Will help a lot for later functions as well. No rep system on this forum it seems so +rep anyways I have never done php until yesterday so forgive me if I am little slow, I am starting up reading as much information the subject as I can.
  14. I am adding new entries into a MySQL table via a php script. The script works fine, but I want to prevent duplicate entries. How can I check if an entry already exists on the table before initiating the query to write to the table. It is for a user registration type of system. The php script rights "AccountName" and "PassWord" to the table called "Accounts". This was my attempt to check if it exists: $query = "INSERT INTO Accounts(AccountName, Password)VALUES ('".$Accn."','".$Pwwd."')"; $Check = mysql_query("SELECT * FROM Accounts"); while($row = mysql_fetch_array($Check)) { $Account = $row['AccountName']; } if($accn != Account) { mysql_query($query); } Where $accn = the new accountname entered. I am trying to compare the new AccountName(accn) that was entered with the array of all AccountNames already in the database, and if does not already exists, then add it.
  15. Hey, thanks for trying to help. I figured out the issue and have it working now. It really helped out a lot re-creating the project in a console app to test with. Using cout allowed to me see some things that my logs were not showing and I figured out why the buffer was not being filled with the correct data.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.