Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Passwords
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
StarGateSG-1




PostPosted: Tue Jan 04, 2005 10:33 pm   Post subject: Passwords

I am making an text based Rpg in C++ to follow up with my many turing text based and i was wondering how to hide a password like so "*****".
I can do it in turing as well as Java but it just won't work. If someone could plz post full source code it would be greatly appreciated! Smile .
By the way I use Dev-C++.

O and if anyone would like to help me it with making this game.
i.e Idea's ,Coding(no C++ exp req but at least java or php or any language with common syntax with C++. If i could get some people with graphics experiance this could become a graphical game.

If you would like to help plz e-mail me.
Help would be much appreciated! Very Happy
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Jan 05, 2005 3:45 am   Post subject: (No subject)

I think you're looking for the getch() function.
Andy




PostPosted: Wed Jan 05, 2005 8:10 am   Post subject: (No subject)

a while back, i made a dating data base program where each user could login and change their information and browse others infos

c++:

        while(1)
        {
                ascii=getch();
                if (ascii==13)
                        break;
                else if (ascii==8 && pwcount>0)
                {
                        system("cls");
                        cout<<username<<" Please Enter your Password ";
                        for(i=1;i<strlen(temp);i++)
                                printf("*");
                        pwcount-=1;
                        temp[pwcount]='\0';
                }
                else if (ascii!=8)
                {
                        printf("*");
                        temp[pwcount]=ascii;
                        pwcount+=1;
                        temp[pwcount]='\0';
                }
        }


I also had an encrpyt/decpypt function within the program

c++:

//encryption program
string encrypt(char word[])
{
        //used for holding data
        char tempword[15],final[15];
        int val[15],j,tempval;
        string encrypted;

        //encrypt the data
        for (int i=0;i<strlen(word);i++)
                val[i]=i;

        for (i=0;i<strlen(word);i++)
        {
                j=rand()%strlen(word);
                tempval=val[i];
                val[i]=val[j];
                val[j]=tempval;
        }

        for (i=0;i<strlen(word);i++)
        {
                tempword[i]=word[val[i]];
                final[i]=val[i]+48;
        }
       
        tempword[strlen(word)]='\0';

        final[strlen(word)]='\0';
        strcat(final,tempword);

        for (i=0;i<strlen(final);i++)
                final[i]+=((i%3)-1)*i;

        encrypted=final;
        return encrypted;
}

//decryption program
string decrypt(string word)
{
        //used for holding data
        char tempword[15],final[15];
        int val[15];
        string decrypted;
        for (int i=0;i<word.length();i++)
                final[i]=word[i];
        final[word.length()]='\0';
        for (i=0;i<strlen(final);i++)
                final[i]-=((i%3)-1)*i;

        for (i=0;i<strlen(final)/2;i++)
        {
                val[i]=final[i]-48;
                tempword[i]=final[i+(strlen(final)/2)];
        }

        tempword[strlen(final)/2]='\0';
        for (i=0;i<strlen(tempword);i++)
                final[val[i]]=tempword[i];

        final[strlen(tempword)]='\0';
       
        decrypted=final;
        return decrypted;
}

the reason why i had both an encryption and decryption program is because the same word can be encrypted differently cuz it is a random encryption.
the entire program is based around binary trees.. i'll post the source so you can take an look at what i did, but if u dont know anything about binary trees, dont bother learning it on ur own.. it mite be quite painful, especially if your new to programming

Martin was here (to show off the fancy new syntax tags).



Love Bytes.zip
 Description:

Download
 Filename:  Love Bytes.zip
 Filesize:  769.94 KB
 Downloaded:  231 Time(s)

StarGateSG-1




PostPosted: Wed Jan 05, 2005 6:18 pm   Post subject: (No subject)

Ya that source code you gave me won't run in my Dev C++.
It is very good and I am new c++ but i have a great background in java so i understand the code but can't for the life of me frigure out why it won't work. Any idea's
Tony




PostPosted: Wed Jan 05, 2005 9:39 pm   Post subject: (No subject)

what kind of an error message does the compiler return?
wtd




PostPosted: Wed Jan 05, 2005 9:47 pm   Post subject: (No subject)

Dev-C++ is based on G++. The getch() function is Windows-only (at least in this form), and GCC doesn't generally include Winows-specific headers. You can install and use them with GCC, though.
StarGateSG-1




PostPosted: Thu Jan 06, 2005 8:36 am   Post subject: (No subject)

Quote:
what kind of an error message does the compiler return?


The complier returns "cannot run error".
No data no idea's just that.
That is on his whole dating service program.
StarGateSG-1




PostPosted: Thu Jan 20, 2005 11:52 am   Post subject: (No subject)

I need a reponse plz
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Thu Jan 20, 2005 5:11 pm   Post subject: (No subject)

haha sry.. i was too busy in the last couple of days... umm hmm do u have any question regarding the pasword masking code that i posted? i mean.. unless u can acquire a copy of vc.. i dont see how ur gona compile and run my program... however, if u want, i can post the exe version of it Confused
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: