old_contents: import brainfuck
  import scrypt
  import prng
  
  def hash(password, salt):
      k0 = scrypt.hash(password, salt, 512, 4, 8, 96)
      code_key = k0[ 0:32]
      data_key = k0[32:64]
      code_iv  = k0[64:80]
      data_iv  = k0[80:96]
      code_rng = prng.AESCTR(code_key, code_iv)
      data_rng = prng.AESCTR(data_key, data_iv)
      code = brainfuck.BFG(code_rng).random_bf(1024)
      print(code)
      vm = brainfuck.BFJIT(code, 65536)
      b = bytes(vm.eval(data_rng.bytes(), 1000000))
      print(b)
      k1 = scrypt.hash(b, salt, 512, 4, 8, 32)
      return scrypt.hash(k1 + password, salt, 512, 4, 8, 32)
  
  
new_contents: import brainfuck
  import scrypt
  import prng
  
  def hash(password, salt):
      """The hash function you want to call."""
  
      k0 = scrypt.hash(password, salt, 512, 4, 8, 48)
      debug("k0", k0)
      rng = prng.AESCTR(k0[:32], k0[32:])
      b = run_brainfuck(rng)
      k1 = scrypt.hash(b, salt, 512, 4, 8, 32)
      debug("k1", k1)
      key = scrypt.hash(k1 + password, salt, 512, 4, 8, 32)
      debug("key", key)
      return key
  
  def run_brainfuck(rng):
      """Futile attempt to preseve randomness."""
  
      output = b''
      
      while len(output) < 48 or len(set(output)) < 44:
          code = brainfuck.BFG(rng).random_bf(1024)
          vm = brainfuck.BFJIT(code, 65536)
          chunk = bytes(vm.eval(rng.bytes(), 1000000))
          debug("chunk", chunk)
          output += chunk
  
      return output
  
  def debug(label, data):
      return
      d =  ''.join([ hex(b)[2:].rjust(2, '0') for b in data ])
      d = d if len(d) < 100 else d[:50] + '...' + d[-50:]
      print(label, '=', d, 'bytes =', len(data), 'unique bytes =', len(set(data)))
  
subject: Make some attempt to preserve randomness. Use only 1 AES CTR step.