Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am going to create a project on c language.
i just wanna know that how to convert user input(like password) in ***(in encrypted form) and compare it with existing password.
Posted
Comments
Stefan_Lang 27-Jan-14 3:03am    
The way you posed your question reminded me of this:
http://dilbert.com/fast/2001-09-06/

:o)

Your tags say "C++, C, Java" - so we can't be precise with any answer: a Java solution for Android would be very different from a C++ solution for .NET or a C solution for a console app.
But...

First, don't encrypt passwords: hash them instead. The explanation as to why is here: Password Storage: How to do it.[^] - but teh code is in C#, so it probably isn;t a lot of use to you! Depending on your language / compiler / environment there will be similar functions available though.

Second, the use of "****" instead of the password is not encryption either! All that is it the Textbox being set to use the Password character so it isn't echoed on the screen so teh guy looking over your shoulder can read it! :laugh:
Exactly how you do that will also depend on the language and environment in which you are trying to work, so we can't tell you how to do that either!
 
Share this answer
 
In C++ with Winapi:
You can use ES_PASSWORD visual style constant when you create the user input editbox with
CreateWindow function.

Please see this:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb775464(v=vs.85).aspx[^]

This style just a special showing for the inputted text, so
after than, you can compare it with your user-password database
 
Share this answer
 
v3
#include<iostream>
#incldue<conio.h>

using namespace std;

char originalPass[8] = {'1','1','1','1','1','1','1','1'};
bool condition = true;


int main()
{
char *getPass;
int count=0;

cout<<"Enter Password";
while((x = getch()) != 32)
{
cout<<"*";
getPass[count] = x;
count++;
}

for(int i = 0;i<count;i++)>
{
if(originalPass[i] != getPass[i])
{
condition = false;
break;
}
}

if (condition==true)
cout<<"Password Correct";
else
cout<<"password incorect";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900