Buscar este blog

miércoles, 6 de febrero de 2013

A simple function that hides typed passwords in C++

In C++ console there's no way of hiding passwords at the same time we type them (I mean, our password remains visible for everyone who may sit next to us). There's a simple way to avoid this that resembles to what can be easily made in HTML or JavaScript: simply adding a cls command to clear all the console output until that moment and then popping up the same stuff but now with '*' instead.

Code:

4 comentarios:

  1. You are wrong....see and execute the following code snippet
    {
    clrscr();
    cout<<endl<<"Ultimate Quiz Password Authentication"
    <<endl<<endl<<"Enter current password: ";
    for (int i = 0; ;i++)
    {
    check[i] = getch();
    if (check[i] == '\r')
    break;
    cout<<"*";
    }
    I myself am a programmer and your mutating encryption algorithm was really awesome and simple at the same time

    ResponderEliminar
    Respuestas
    1. I had no idea of how to do it, but your snippet works perfectly!! Thanks so much :)

      Eliminar
    2. Thanks.....do u know some really good encryption algorithm that can be broken by school students in about an hour or so ?

      Eliminar
    3. Dear Ashutosh, sorry for the delay.

      Maybe you could use a very simple encryption algorithm which basically consists on mapping all characters into the numerical ASCII code, then adding to each one 'k' (being k an integer).

      Thank you very much.

      Eliminar