Created
December 14, 2011 16:03
-
-
Save dketov/1477170 to your computer and use it in GitHub Desktop.
Криптографические функции
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Вычисление хэша | |
""" | |
import hashlib | |
m = hashlib.md5() | |
m.update("Nobody inspects") | |
m.update(" the spammish repetition") | |
m.digest() | |
m.digest_size | |
m.block_size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Кодировка base64 | |
""" | |
import base64 | |
encoded = base64.b64encode('data to be encoded') | |
print encoded | |
data = base64.b64decode(encoded) | |
print data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Koд аутентификации сообщения HMAC | |
""" | |
import hmac | |
m = hmac.new('password') | |
m.update("Nobody inspects") | |
m.update(" the spammish repetition") | |
m.digest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment