shaã¨ãhashlibã¨ã
python2.6ã«ãªã£ã¦ãmd5ã¢ã¸ã¥ã¼ã«ã¨shaã¢ã¸ã¥ã¼ã«ãã¤ã³ãã¼ãããã¨
>>> import md5 __main__:1: DeprecationWarning: the md5 module is deprecated; use hashlib instead >>> import sha __main__:1: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
ã¯ã¼ãã³ã°ãåºã¦ãããã¯ã¼ãã³ã°ã¯åºããã©ã使ããªãäºã¯ãªãããããããããpython3.0ã ã¨
>>> import md5 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named md5 >>> import sha Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named sha
ãããªãããªãããã¨ã¨ã©ã¼ã«ãªãããããªã使ããªãã
shaã¨ãmd5ã¯ãããããªã¢ã¸ã¥ã¼ã«ã§ä½¿ããã¦ãããããWebApiã®ã©ã¤ãã©ãªã¯ã»ã¨ãã©ä½¿ã£ã¦ããã®ã§ãããªãã®ç¢ºçã§ä¸è¨ã®ã¯ã¼ãã³ã°ãåºããä»ã¾ã§ã¯æ°ã«ããªãã£ããã©ããã®ãã¡Python3.0軸足ã«ãªã£ãæã«ãããªã使ããªããªã£ã¦ãå°ãã®ã¯èªåã ãã¨ãããã¨ã§ãã¡ããã©ãid:yoshioriãããå
¬éãã¦ãããhatenadããpython2.6ã§ã¯ã¼ãã³ã°ã§ãªãããã«ãã¦ã¿ãã
import sha
ã¨ãªã£ã¦ããæã
from hashlib import sha1 as sha
ã¨ãã¦ã¢ã¸ã¥ã¼ã«ã®èªã¿è¾¼ã¿å ãå¤ãã¦
-return '%s %s' % (timestamp, sha.new('%s:%s' % (timestamp, private)).hexdigest()) +return '%s %s' % (timestamp, sha('%s:%s' % (timestamp, private)).hexdigest()) -password_digest = base64.encodestring(sha.new(nonce + post_creation_time + self.passwd).digest()).replace('\n', '') +password_digest = base64.encodestring(sha(nonce + post_creation_time + self.passwd).digest()).replace('\n', '')
newããªãã¦ãããã½ãã®ã§ããããå¤ãã
ã¨ããã¨ã¾ã§ãã£ã¦ãæããpullãªã¯ã¨ã¹ããéã£ã¦ãã¾ã£ãã
ãã®ã³ã¼ãã ã¨ãpython2.6以ä¸ã ã¨æ£å¸¸åä½ããããpython2.5ã ã¨ãåããªãã»ã»ã»
ãã¼ãããªãã¾ããã
å端ãªã³ã¼ãéã£ã¦ããããªãã