Skip to content

Instantly share code, notes, and snippets.

@minektur
Created March 8, 2019 23:58
Show Gist options
  • Save minektur/5af2fd55250fccc426da5cb4bfe3284b to your computer and use it in GitHub Desktop.
Save minektur/5af2fd55250fccc426da5cb4bfe3284b to your computer and use it in GitHub Desktop.
Freds-MacBook-Pro:html fred$ python3
Python 3.7.2 (default, Dec 27 2018, 07:35:06)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import crypt
>>> dir(crypt)
['METHOD_BLOWFISH', 'METHOD_CRYPT', 'METHOD_MD5', 'METHOD_SHA256', 'METHOD_SHA512', '_Method', '_SystemRandom', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_crypt', '_namedtuple', '_saltchars', '_sr', '_string', 'crypt', 'methods', 'mksalt']
>>> crypt.METHOD_MD5
<crypt.METHOD_MD5>
>>> crypt.crypt.__doc__
'Return a string representing the one-way hash of a password, with a salt\n prepended.\n\n If ``salt`` is not specified or is ``None``, the strongest\n available method will be selected and a salt generated. Otherwise,\n ``salt`` may be one of the ``crypt.METHOD_*`` values, or a string as\n returned by ``crypt.mksalt()``.\n\n '
>>> help(crypt.crypt)
>>> crypt.crypt("some random text", crypt.METHOD_MD5)
'$1aFAGx3O0Uvc'
@minektur
Copy link
Author

minektur commented Mar 9, 2019

[root@mustang002 ~]# uname -a
Linux mustang002 3.10.0-862.6.3.el7.x86_64 #1 SMP Tue Jun 26 16:32:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@mustang002 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@mustang002 ~]# python
Python 2.7.5 (default, Apr 11 2018, 07:36:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import crypt
crypt.crypt("some text", crypt.METHOD_MD5)
'$1$x/C32anp$n6sTQmIBDai.h/QtucIq..'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment