반응형

파이썬에서 sha, md5 해시값을 구해보자.


설명이 많이 필요없을 듯하고 그냥 코드를 통해 어떻게 쓰는지 알고 넘어가면 좋을 것 같다.


이 코드는 모두 파이썬 2에서 작성한 코드이다.



SHA 해쉬값


1
2
3
4
5
6
7
8
9
10
import hashlib
 
string = raw_input()
sha = hashlib.new('sha')
 
sha.update(string)
print sha.hexdigest()
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus



SHA-1 해쉬값


1
2
3
4
5
6
7
8
9
10
import hashlib
 
string = raw_input()
sha = hashlib.new('sha1')
 
sha.update(string)
print sha.hexdigest()
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus




SHA-224 해쉬값


1
2
3
4
5
6
7
8
9
10
import hashlib
 
string = raw_input()
sha = hashlib.new('sha224')
 
sha.update(string)
print sha.hexdigest()
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus


SHA-256 해쉬값


1
2
3
4
5
6
7
8
9
10
import hashlib
 
string = raw_input()
sha = hashlib.new('sha256')
 
sha.update(string)
print sha.hexdigest()
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus


SHA-384 해쉬값


1
2
3
4
5
6
7
8
9
10
import hashlib
 
string = raw_input()
sha = hashlib.new('sha384')
 
sha.update(string)
print sha.hexdigest()
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus



SHA-512 해쉬값


1
2
3
4
5
6
7
8
9
10
import hashlib
 
string = raw_input()
sha = hashlib.new('sha512')
 
sha.update(string)
print sha.hexdigest()
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus



MD5 해쉬값


1
2
3
4
5
6
7
8
9
10
import hashlib
 
string = raw_input()
sha = hashlib.new('md5')
 
sha.update(string)
print sha.hexdigest()
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus




반응형