readpass - Man Page

read password


Readpass library (librpass, -lrpass)


#include <readpass.h>

char * readpass(const char * prompt, char display, size_t len);


The readpass() function reads in password from standard input. readpass displays the prompt, turns off character echo, and reads the password string of up to len number of characters or till a newline character, whichever occurs first. While reading password, readpass shows display character instead of actual input entered by user, and then turns on the character echo.

Return Value

readpass returns pointer to a dynamically allocated buffer holding the password, or NULL otherwise.


The pointer returned, points to the password in its clear text form, thus user should take care of its confidentiality.

Secondly, don't forget to release memory (free(3)) allocated by readpass to store password.


If you encounter any problems/bugs in working of readpass(), please send an email to <pj.pandit AT> mentioning about problem/bug; while doing so, do include 'readpass()' string in the subject line.

See Also

tlock(1) free(3)  crypt(3)


Prasad J Pandit <pj.pandit AT>

Referenced By