It is easy for you to use hash by Ipython.
IPython is a rich archtecture for interactive computing which is powerful extended from Python.
It provides below;
- Powerful interactive shells (terminal and Qt-based).
- A browser-based notebook with support for code, text, mathematical expressions, inline plots and other rich media.
- Support for interactive data visualization and use of GUI toolkits.
- Flexible, embeddable interpreters to load into your own projects.
- Easy to use, high performance tools for parallel computing.
how do hash?
Let’s start Ipython in terminal and type import command.
In : import hashlib
A special feature of Ipython is function of complement. You press
[TAB] key with typing below command.
In : hashlib. hashlib.algorithms hashlib.new hashlib.sha224 hashlib.sha384 hashlib.md5 hashlib.sha1 hashlib.sha256 hashlib.sha512
In this case, i will use hashlib.md5, type below the command.
In : x = hashlib.md5("hello") In : x Out: In : x.hexdigest() Out: '5d41402abc4b2a76b9719d911017c592' Out is hash value. And You have another way that type under the command. In : hashlib.md5("helloworld").hexdigest() Out: 'fc5e038d38a57032085441e7fe7010b0'
So MD5 is insufficiency security, because It is very easy to decode hash by malicious user who knows algorithm of using at your WebPage.There are some way which is better security than MD5. HMAC is one of those way. HMAC is a way which gives a secret key to subject of hash. Because this secret key is’t known from malicious user, you prevent decoding of hash. Let’s type below command.
In : import hmac In : SECRET = "secretkey" In : hmac.new(SECRET,"helloworld").hexdigest() Out: 'f5ea2a8229b8fdfaf207316dfd265995'
This case of HMAC is that SECRET which defined by option string appends subject of hash. I wish remember this Tips in future:)