15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonでソルト付きでハッシュ計算をする方法

Last updated at Posted at 2014-08-13

hashlibモジュールがありますので、簡単に実装することが可能です。
ソルト付きとタイトルに書いていますが、「Salt+Data」をhashlibにかければ良いわけでこれまた簡単です。

・実装方法

#!/usr/bin/env python

import hashlib

message = "salt" + "data"

print "MD5: " + hashlib.md5(message).hexdigest()
print "sha256: " + hashlib.sha256(message).hexdigest()
print "sha516: " + hashlib.sha512(message).hexdigest()
~~~~~~~

ここではmd5とsha256、sha516を使用。

#### ・確認

./hash.py

MD5: 23eeeb4347bdd26bfc6b7e・・・
sha256: 11a4a60b518bf24989d481468076e5d59828846265b857・・・
sha516: ecc579811643b170cbd88fd0d0e323d1e1acc7cef8f73483a7・・・


出力が長くて改行で見づらくなったため、「・・・」で省略しました。
実際はもっと長いです(特にsha512)
15
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?