Close Back

      1  /*
      2  *	passwords.h
      3  *
      4  *****************************************************************************
      5  *
      6  *	Get passwords in C
      7  *     	~~~~~~~~~~~~~~~~~~
      8  *****************************************************************************
      9  *
     10  *     	Author           :  Rajesh _ThE gReAt
     11  *	Built on         :  Some time in 2k
     12  *	Last Modified on :  Friday, February 15, 2002, 11:45:58 PM
     13  *
     14  *
     15  *	Known errors : ---===(none)===---
     16  *
     17  *****************************************************************************
     18  *	DISCLAIMER:
     19  *****************************************************************************
     20  *
     21  *	Programmers may incorporate any or all code into their programs,
     22  *	giving proper credit within the source. Publication of the
     23  *	source routines is permitted so long as proper credit is given
     24  *	to Rajesh _ThE gReAt.
     25  *
     26  *	Copyright (C) 2002, 2003 by Rajesh _ThE gReAt.  You may use this program, or
     27  *	code or tables extracted from it, as desired without restriction.
     28  *	I can not and will not be held responsible for any damage caused from
     29  *	the use of this software.
     30  *
     31  *	Read license.txt from http://www.rajeshgoli.com/license.txt
     32  *	                   or http://www.rajeshgoli.com/license.htm
     33  *	before using / distributing / or any sort of use of my source
     34  *	Also read my disclaimer http://www.rajeshgoli.com/disclaimer.htm
     35  *	
     36  *	YOU AGREE TO BE BOUND BY MY DISCLAIMER AND LICENSE BY IN ANY WAY
     37  *	USING THIS FILE .
     38  *
     39  *****************************************************************************
     40  * This source works with Turbo C 2.0 and Turbo C++ 3.0 and above.
     41  *****************************************************************************
     42  *	Rajesh _ThE gReAt is a synonym of Rajesh Goli
     43  *	Source freely distributable 
     44  *****************************************************************************/
     45  
     46  #define OUTCHAR '*'
     47  
     48  #ifndef __STDIO_H
     49  #include<stdio.h>
     50  #endif
     51  
     52  #ifndef __CONIO_H
     53  #include<conio.h>
     54  #endif
     55  
     56  char *getpassword(char *write)
     57  {
     58  	char ch;
     59  	char *pass;
     60  	char *work;
     61  	work=pass;
     62  	putc('\n',stdout);
     63  	while(*write)
     64  		putchar(*(write++));
     65  	do
     66  	{
     67  		ch = getch();
     68  		*(pass++)=ch;
     69  	}
     70  	while(ch != '\r');
     71  	*(--pass)=0;		/*Replace '\r' by NULL charecter*/
     72  	return(work);
     73  }
     74  
     75  char *getpass_star(char *write)
     76  {
     77  	char ch;
     78  	char *pass;
     79  	char *work;
     80  	work=pass;
     81  	putc('\n',stdout);
     82  	while(*write)
     83  		putchar(*(write++));
     84  	do
     85  	{
     86  		ch = getch();
     87  		*(pass++)=ch;
     88  		if(ch!='\r')
     89  			putc(OUTCHAR,stdout);
     90  	}
     91  	while(ch != '\r');
     92  	*(--pass)=0;		/*Replace '\r' by NULL charecter*/
     93  	return(work);
     94  }
     95