Little boy questioned his mother, he asked what he can be in the future..with a sad smile, she tells him he can be anything he wants to be.... Boy said he’d become (an) astronaut and fly out into space crews around the universe he wanted to see the stars and also see other planets in outer space------------- "Why don’t we just keep dreaming, let’s keep our mind with dream and faith, as long as we wish we can make it come true, how old you are never forget your dream and keep dreaming "

Saturday 8 December 2018

Python : Input password pada Python dengan getpass()


Ketika program meminta user untuk memasukan password/katasandi tentunya kita tidak ingin password yang sedang kita ketik muncul dilayar.

getpass (), fungsi yang meminta pengguna untuk memasukan kata sandi tanpa menampilkannya. Module getpass menyediakan cara yang aman untuk menangani permintaan kata sandi di mana program berinteraksi dengan pengguna melalui terminal/command prompt.

Contoh penggunaan pada validasi login user
Sintaks nya :


import getpass
userid = 'gani'
passw = 'secret'

uid = input('masukan id anda : ')
pwd = getpass.getpass('masukan password anda : ')
if uid == userid and pwd == passw :
    print('Sukses Login..Selamat datang ', userid)
else :
    print('User ID atau password salah')

Jika dijalankan hasilnya seperti ini :

Done..


No comments:

Post a Comment