emery Posted August 1, 2012 Share Posted August 1, 2012 I nee an encryption code for php that will do this, if someone could write it i would be more then happy! This is how to decode it, if you can figure out ow to encode it that would be awsome longstring = "6804564035410064404403402418540676879840602880370546710354657057035406870564064340640810564097523824" To decode you peal off the first two digits from C$ and use that to relocate the position of the first digit in the long string. Then take it and the next 7 digits to make B$. Falsely subtract C$ minus B$ and you get the date back in A$. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 1, 2012 Share Posted August 1, 2012 This sounds like a school project, or something similar, and as such meant for you to figure out yourself. We won't write your code for you, in any case. Also, you have the step-by-step description of how to do this, all you need to do is to translate it into code. If you cannot do that, then you really need to learn the language. Quote Link to comment Share on other sites More sharing options...
emery Posted August 1, 2012 Author Share Posted August 1, 2012 Noo, it's for my software, i have the code in quick basic, but i need the code in php, which i don't know much of proof: COLOR 15, 1: CLS 'ENCRYPT A$ -> C$ RANDOMIZE TIMER N$ = "6804564035410064404403402418540676879840602880370546710354657057035406870564064340640810564097523824" A$ = "20120731" N = INT(RND(9) * 81 + 10) PRINT N B$ = MID$(N$, N, C$ = "" FOR A = 1 TO 8 X = VAL(MID$(A$, A, 1)) + VAL(MID$(B$, A, 1)) IF X > 9 THEN X = X - 10 C$ = C$ + LTRIM$(STR$(X)) NEXT C$ = LTRIM$(STR$(N)) + C$ PRINT C$ 'DECRYPT C$ -> A$ RANDOMIZE TIMER N$ = "6804564035410064404403402418540676879840602880370546710354657057035406870564064340640810564097523824" N = VAL(LEFT$(C$, 2)) C$ = RIGHT$(C$, B$ = MID$(N$, N, A$ = "" FOR A = 1 TO 8 X = VAL(MID$(C$, A, 1)) - VAL(MID$(B$, A, 1)) IF X < 0 THEN X = X + 10 A$ = A$ + LTRIM$(STR$(X)) NEXT PRINT A$ Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 1, 2012 Share Posted August 1, 2012 Well, then you have almost the exact code you need. You just need some minor syntax rewriting, and replace mid, left and right with substr () All of which should be quickly done after a quick look in the PHP manual. BTW: What's that RANDOMIZE TIMER doing in the decrypt routine? Quote Link to comment Share on other sites More sharing options...
emery Posted August 1, 2012 Author Share Posted August 1, 2012 It just kinda felt like being there .... bad poker face.jpg Quote Link to comment Share on other sites More sharing options...
emery Posted August 1, 2012 Author Share Posted August 1, 2012 <?php RANDOMIZE TIMER $N = "6804564035410064404403402418540676879840602880370546710354657057035406870564064340640810564097523824"; $A = "20120731"; N = INT(RND(9) * 81 + 10); ECHO N; $B = MID$(N$, N, ; $C = ""; FOR A = 1 TO 8 X = VAL(MID$(A$, A, 1)) + VAL(MID$(B$, A, 1)) IF (X > 9) { X = X - 10; } $C = $C . LTRIM$(STR$(X)) NEXT $C = LTRIM$(STR$(N)) . $C; echo $c; ?> That is what i have now, but i don't know how to change the rest Quote Link to comment Share on other sites More sharing options...
emery Posted August 1, 2012 Author Share Posted August 1, 2012 Could you please help :'( Quote Link to comment Share on other sites More sharing options...
emery Posted August 1, 2012 Author Share Posted August 1, 2012 Ok, i have gotten this far, but how do i do the loop for next? <?php RANDOMIZE TIMER $N = "6804564035410064404403402418540676879840602880370546710354657057035406870564064340640810564097523824"; $A = "20120731"; N = INTVAL(rand(10, 91); ECHO N; $B = SUBSTR(N$, N, ; $C = ""; FOR A = 1 TO 8 X = INTVAL(SUBSTR($A, A, 1)) + INTVAL(SUBSTR(B$, A, 1)); IF (X > 9) { X = X - 10; } $C = $C . X; NEXT $C = N . $C; echo $c; ?> Quote Link to comment Share on other sites More sharing options...
peipst9lker Posted August 1, 2012 Share Posted August 1, 2012 FOR A = 1 TO 8 for ($a=1; $a<=8; $a++) { // do something... } Quote Link to comment Share on other sites More sharing options...
emery Posted August 1, 2012 Author Share Posted August 1, 2012 Ok, thank you, this is what i have but it does not work ... <?php RANDOMIZE TIMER $N = "6804564035410064404403402418540676879840602880370546710354657057035406870564064340640810564097523824"; $A = "20120731"; N = INTVAL(rand(10, 91); ECHO N; $B = SUBSTR(N$, N, ; $C = ""; for ($a=1; $a<=8; $a++) { X = INTVAL(SUBSTR($A, A, 1)) + INTVAL(SUBSTR(B$, A, 1)); IF (X > 9) { X = X - 10; } $C = $C . X; } $C = N . $C; echo $c; ?> Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 1, 2012 Share Posted August 1, 2012 Have you read in the PHP manual for the basic syntax of the language, as well as substr ()? We're not here to write the code for you, you know, but to help people who've tried, got stuck, and generally wants to learn. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.