| 
									
										
										
										
											2017-06-13 22:21:31 -04:00
										 |  |  | #!/usr/bin/python | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import getpass | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-05 21:22:16 -04:00
										 |  |  | import scrypt  # pip install scrypt | 
					
						
							|  |  |  | import binascii | 
					
						
							| 
									
										
										
										
											2017-08-13 19:43:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 22:21:31 -04:00
										 |  |  | password1 = getpass.getpass() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | print('Repeat the same password:') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | password2 = getpass.getpass() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if password1 == password2: | 
					
						
							| 
									
										
										
										
											2017-09-05 21:22:16 -04:00
										 |  |  |     # salt is constant | 
					
						
							|  |  |  |     salt = "dc73b57736511340f132e4b5521d178afa6311c45e0c25e6a9339038507852a6" | 
					
						
							| 
									
										
										
										
											2017-06-13 22:21:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-05 21:22:16 -04:00
										 |  |  |     hashed = scrypt.hash(password=password1, | 
					
						
							|  |  |  |                            salt=salt, | 
					
						
							|  |  |  |                            N=16384, | 
					
						
							| 
									
										
										
										
											2017-09-08 20:55:24 -04:00
										 |  |  |                            r=8, | 
					
						
							| 
									
										
										
										
											2017-09-05 21:22:16 -04:00
										 |  |  |                            p=1, | 
					
						
							|  |  |  |                            buflen=32) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     print('Generated password hash:') | 
					
						
							|  |  |  |     print(binascii.hexlify(hashed)) | 
					
						
							| 
									
										
										
										
											2017-06-13 22:21:31 -04:00
										 |  |  | else: | 
					
						
							|  |  |  |     print('Entered passwords are not identical!') |