Posted By

eiger824 on 02/07/13


Tagged

hide console to passwords on how the


Versions (?)

Hiding Passwords With C++


 / Published in: C++
 

URL: http://programmingeiger824.blogspot.com

In C++ console there's no way to make our passwords invisible when typing them. Here is a really simple funcion that resembles the behavior of hiding passwords.

  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. void askForSecretPassword(void){
  6. string password;
  7. cout<<"Enter your password: ";
  8. cin>>password;
  9. int len=password.length();
  10. system("cls");
  11. cout<<"Enter numeric password: ";
  12. for(int i=0;i<len;i++){
  13. cout<<"*";
  14. }cout<<endl;
  15. };
  16. void main(){
  17.  
  18. askForSecretPassword();
  19. system("pause");
  20.  
  21. }

Report this snippet  

You need to login to post a comment.