# Hide "gets" method output, for passwords

**URL:** <https://www.ruby-forum.com/t/hide-gets-method-output-for-passwords/165180>\
**Category:** Ruby\
**Created:** [April 9, 2009, 10:23pm UTC](https://www.ruby-forum.com/t/hide-gets-method-output-for-passwords/165180 "2009-04-09T22:23:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianwisti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@brianwisti](https://www.ruby-forum.com/u/brianwisti)\
**Post date:** [April 9, 2009, 10:23pm UTC](https://www.ruby-forum.com/t/hide-gets-method-output-for-passwords/165180/1 "2009-04-09T22:23:12Z")

</div>

HI All,

I’m trying to find a platform independent way of hiding the STDOUT when  
a  
password is being entered via the gets method…  
I was able to hide all output in Linux by using Termios , but as you  
know  
this doesn’t work on Windows…

What would be nice , is a simple implementation of asterisks replacing  
the  
actual characters displayed to STDOUT …

Does anyone know if this is possible in Ruby?

Thanks,

draygen

---

<div class="post-metadata">

**Author:** ![brianwisti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@brianwisti](https://www.ruby-forum.com/u/brianwisti)\
**Post date:** [April 9, 2009, 11:07pm UTC](https://www.ruby-forum.com/t/hide-gets-method-output-for-passwords/165180/2 "2009-04-09T23:07:46Z")

</div>

On Apr 9, 3:22 pm, Brian W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What would be nice , is a simple implementation of asterisks replacing the  
> actual characters displayed to STDOUT …
> 
> Does anyone know if this is possible in Ruby?

I’m not sure because I haven’t done this sort of thing myself, but I  
imagine the highline gem is a good place to look.

[http://highline.rubyforge.org/](http://highline.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![brianwisti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@brianwisti](https://www.ruby-forum.com/u/brianwisti)\
**Post date:** [April 9, 2009, 11:10pm UTC](https://www.ruby-forum.com/t/hide-gets-method-output-for-passwords/165180/3 "2009-04-09T23:10:06Z")

</div>

Brian W. wrote:

> Does anyone know if this is possible in Ruby?
> 
> Thanks,
> 
> draygen

I think Highline will do this: [http://highline.rubyforge.org](http://highline.rubyforge.org)
