use crypt function
python lib of crypt:
root@kali:~/dc# python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import crypt
>>> crypt.crypt("egg","HX")
'HX9LLTdc/jiDE'
>>> help('crypt')