Can someone help me fix this code? 
Author Message
 Can someone help me fix this code?

It is suppose to decrypt a "encrypted" password...
One encrypted password is: `XR`ZKWZH the decrypted version of that is
UNIXSERVER

BUT, the program puts junksigns after the real password, what to do?

The algorithm is, take the ascii value of the first letter -11, the
new ascii value is the right character for the new password. Take the
next char -10 the next -9 until it's finished...

What to do?

........................................................

Code starts here:

#include <string.h>
#include <stdio.h>

#define MAX_CHAR 13

void decrypt(char *temp,char var_decoded[]);

void main(void)
        {
        char var_encoded[MAX_CHAR],
        var_decoded[MAX_CHAR];

                printf("
                \nDecrypter ver 1.10\n\n
                Encryption cracked by Sucker\n
                Coded by G-ZPOT with changes made by Sucker\n\n
                Type the encrypted password:");

                gets(var_encoded);
                decrypt(var_encoded,var_decoded);
                printf("\nDecrypted password is %s\n",var_decoded);
                return;

        } //End main

void decrypt(char *temp,char var_decoded[])
        {
        int i,i2;
        char t[MAX_CHAR];

        for(i=0,i2=11;*temp!='\0';i++,i2--)
                {
                t[i]=*temp-i2;
                temp++;
                }
                strcpy(var_decoded,t);

        }



Sun, 18 Jun 2000 03:00:00 GMT  
 Can someone help me fix this code?

: It is suppose to decrypt a "encrypted" password...
: One encrypted password is: `XR`ZKWZH the decrypted version of that is
: UNIXSERVER

: BUT, the program puts junksigns after the real password, what to do?

: The algorithm is, take the ascii value of the first letter -11, the
: new ascii value is the right character for the new password. Take the
: next char -10 the next -9 until it's finished...

/* The algorithm is incomplete - are both, or either, of the passwords
 * intended to be printable characters.  Note that the example shows
 * 9 characters being decoded to 10.
 */

: What to do?

: ........................................................

: Code starts here:

: #include <string.h>
: #include <stdio.h>

: #define MAX_CHAR 13

: void decrypt(char *temp,char var_decoded[]);

/* ... char *var_decoded would make more sense here */

: void main(void)
:       {
:       char var_encoded[MAX_CHAR],
:       var_decoded[MAX_CHAR];
:      
:      
:                 printf("
:               \nDecrypter ver 1.10\n\n
:               Encryption cracked by Sucker\n
:               Coded by G-ZPOT with changes made by Sucker\n\n
:               Type the encrypted password:");

/* Not all implementations accept this form of string */

:               gets(var_encoded);

/* Do _not_ use gets; for reasons see the FAQ */

:               decrypt(var_encoded,var_decoded);
:                 printf("\nDecrypted password is %s\n",var_decoded);
:                       return;

:       } //End main

/* Not all implementations accept this form of comment */

: void decrypt(char *temp,char var_decoded[])
:       {
:       int i,i2;
:       char t[MAX_CHAR];

:       for(i=0,i2=11;*temp!='\0';i++,i2--)
:               {
:               t[i]=*temp-i2;
:               temp++;
:               }

/* The loop exits when *temp == '\0', and hence t is never
 * terminated with a '\0'.  Add t[++i] = '\0'; after the loop.
 * You may as well stick temp++ in the for statement, as well.
 */
:                 strcpy(var_decoded,t);
/* strcpy copies null-terminated strings; in this case, it copies
 * from t[0] until it finds a null in the junk on the stack, and
 * probably overwrites the var_decoded buffer. Use strncpy wherever
 * possible.
 */
:       }

Will



Sun, 18 Jun 2000 03:00:00 GMT  
 Can someone help me fix this code?


says...

Quote:

>It is suppose to decrypt a "encrypted" password...
>One encrypted password is: `XR`ZKWZH the decrypted version of that is
>UNIXSERVER

>BUT, the program puts junksigns after the real password, what to do?

>The algorithm is, take the ascii value of the first letter -11, the
>new ascii value is the right character for the new password. Take the
>next char -10 the next -9 until it's finished...

>What to do?

>........................................................

>Code starts here:

>#include <string.h>
>#include <stdio.h>

>#define MAX_CHAR 13

>void decrypt(char *temp,char var_decoded[]);

>void main(void)

You better expect to get strange error messages when this program
exits, and passes back to the OS a random error code, otherwise
change this to 'int main(void)'

Do all newbies use Shildt?

- Show quoted text -

Quote:
>        {
>        char var_encoded[MAX_CHAR],
>        var_decoded[MAX_CHAR];

>                printf("
>                \nDecrypter ver 1.10\n\n
>                Encryption cracked by Sucker\n
>                Coded by G-ZPOT with changes made by Sucker\n\n
>                Type the encrypted password:");

>                gets(var_encoded);
>                decrypt(var_encoded,var_decoded);
>                printf("\nDecrypted password is %s\n",var_decoded);
>                return;

>        } //End main

>void decrypt(char *temp,char var_decoded[])
>        {
>        int i,i2;
>        char t[MAX_CHAR];

>        for(i=0,i2=11;*temp!='\0';i++,i2--)
>                {
>                t[i]=*temp-i2;
>                temp++;
>                }

You are never adding a '\0' (NULL Terminator) to the end of your result
string, and this getting whatever junk follows the end of the string
up to the first '\0' it finds somewhere in memory.

- Show quoted text -

Quote:
>                strcpy(var_decoded,t);

>        }



Tue, 20 Jun 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Can someone please fix this code?

2. Can someone please help me fix this error?

3. Someone Please Help Me - I Help You in Any Software Queries/Programming/Coding

4. Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)

5. Can someone fix this problem

6. Help with compiling a "canned" program

7. Can someone help me to port this short qbasic code to C (linux C)

8. Can someone help me with this code...

9. Could someone help me with this imbedded assembly code

10. Pls help me to fix the code!

11. pls help to fix the code!

12. Help with fix to tab delimted conversion code

 

 
Powered by phpBB® Forum Software