<commit_before>#!/usr/bin/python2

import scrypt
import binascii
import getpass
from hashlib import sha512

def SlowKDF(password, salt, i):
    digest = password
    for counter in range(i):
      print "Iteration %s from %s..." % (counter+1, i)
      digest = scrypt.hash(digest, salt, N = 1048576, r = 8, p = 1, buflen = 128)
    return digest

mypass = getpass.getpass("Passphrase: ")

if mypass != getpass.getpass("Repeat passphrase: "):
  print "ERROR: Passwords do not match."
  quit()

if mypass != getpass.getpass("Repeat passphrase (again): "):
  print "ERROR: Passphrases do not match."
  quit()

mysalt = raw_input("Salt: ")
mynumber = int(input("Number of iterations: "))

mydigest = SlowKDF(mypass, mysalt, mynumber)

print "\n == Version 1 =="

print "\n\nDigest in hex format:", binascii.b2a_hex(mydigest)

print "\n\nDigest in base64 format:", binascii.b2a_base64(mydigest)

print "\n == Version 2 =="

mydigest_v2 = sha512(mypass+mysalt+mydigest).digest()

print "\n\nVersion 2 digest in hex format:", binascii.b2a_hex(mydigest_v2)

print "\n\nVersion 2 digest in base64 format:", binascii.b2a_base64(mydigest_v2)<commit_msg>if longer digest is needed<commit_after>#!/usr/bin/python2

import scrypt
import binascii
import getpass
from hashlib import sha512

def SlowKDF(password, salt, i):
    digest = password
    for counter in range(i):
      print "Iteration %s from %s..." % (counter+1, i)
      digest = scrypt.hash(digest, salt, N = 1048576, r = 8, p = 1, buflen = 128)
    return digest

mypass = getpass.getpass("Passphrase: ")

if mypass != getpass.getpass("Repeat passphrase: "):
  print "ERROR: Passwords do not match."
  quit()

if mypass != getpass.getpass("Repeat passphrase (again): "):
  print "ERROR: Passphrases do not match."
  quit()

mysalt = raw_input("Salt: ")
mynumber = int(input("Number of iterations: "))

mydigest = SlowKDF(mypass, mysalt, mynumber)

print "\n == Version 1 =="

print "\n\nDigest in hex format:", binascii.b2a_hex(mydigest)

print "\n\nDigest in base64 format:", binascii.b2a_base64(mydigest)

print "\n == Version 2 =="

mydigest_v2 = sha512(mypass+mysalt+mydigest).digest()

print "\n\nVersion 2 digest in hex format:", binascii.b2a_hex(mydigest_v2)

print "\n\nVersion 2 digest in base64 format:", binascii.b2a_base64(mydigest_v2)

print "\n == Version 1+2 =="

mydigest_v1plus2=mydigest+mydigest_v2

print "\n\nVersion 1+2 digest in hex format:", binascii.b2a_hex(mydigest_v1plus2)

print "\n\nVersion 1+2 digest in base64 format:", binascii.b2a_base64(mydigest_v1plus2)
{'fraction_non_alphanumeric': 0.136327817178881, 'fraction_numerical': 0.03821907013396375, 'mean_word_length': 4.555798687089715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7001234', 'n_tokens_mistral': 1017, 'n_tokens_neox': 917, 'n_words': 252}