Replace passwords with a secret in a dictionary.
970917
def mask_dict_password(dictionary, secret='***'):
    """"""
    d = dictionary.copy()
    for k in d:
        if 'password' in k:
            d[k] = secret
    return d
1295860
def sanitize_dict(input_dict):
    
    """
    plain_dict = dict()
    for key in input_dict.keys():
        value = input_dict[key]
        if hasattr(value, 'keys'):
            plain_dict[key] = sanitize_dict(value)
        else:
            plain_dict[key] = value
    return plain_dict
450
def delete_keys(self, keys, secret=False):
        '''
        
        '''
        return self.execute(
            DeleteResult(),
            ['--batch', '--yes', '--delete-secret-key' if secret else '--delete-key'] + list(make_list(keys))
        )
84453
def PassphraseCallback(verify=False,
                       prompt1="Enter passphrase:",
                       prompt2="Verify passphrase:"):
  """"""
  while 1:
    try:
      p1 = getpass.getpass(prompt1)
      if verify:
        p2 = getpass.getpass(prompt2)
        if p1 == p2:
          break
      else:
        break
    except KeyboardInterrupt:
      return None
  return p1
56279
def change_password(self, password):
        
        self.update(password_hash=self.encrypt_password(password),
                    require_password_change=False)

        # Whenever the password is changed, reset the secret key to invalidate
        # any tokens in the wild
        self.reset_secret_key()
260487
def update_credentials(self, key, secret):
        '''  '''
        self.access_key = key
        self.secret_key = secret
246348
def _get_passwordkey(self):
        """"""

        sha = SHA256.new()
        sha.update(self.password.encode('utf-8'))
        return sha.digest()
53054
def passwordLogin(self, username):
        
        self.challenge = secureRandom(16)
        self.username = username
        return {'challenge': self.challenge}
397343
def change_password(ctx):
    """"""

    username, passhash = _get_credentials(ctx.obj['username'],
                                          ctx.obj['password'],
                                          ctx.obj['db'])

    change_user = ctx.obj['db'].objectmodels['user'].find_one({
        'name': username
    })
    if change_user is None:
        log('No such user', lvl=warn)
        return

    change_user.passhash = passhash
    change_user.save()

    log("Done")
387536
def secretly(reactor, action, system=None, username=None,
             prompt="Password:"):
    
    if system is None:
        system = action.__module__
        if system == '__main__':
            system = os.path.abspath(sys.argv[0])
    if username is None:
        username = getpass.getuser()
    while True:
        secret = keyring.get_password(system, username)
        if secret is not None:
            break
        pinentry = yield choosePinentry()
        keyring.set_password(
            system, username,
            (yield pinentry.askForPassword(
                reactor, prompt, "Enter Password",
                "Password Prompt for {username}@{system}"
                .format(system=system, username=username)))
        )
    yield maybeDeferred(action, secret)
1012493
def make_keys_safe(dct):
    """"""
    result = {}
    for key, val in dct.items():
        key = key.replace('-', '_')
        if key in keyword.kwlist:
            key = key + '_'
        result[key] = val
    return result
802751
def encode_sid(cls, secret, sid):
        """"""

        secret_bytes = secret.encode("utf-8")
        sid_bytes = sid.encode("utf-8")

        sig = hmac.new(secret_bytes, sid_bytes, hashlib.sha512).hexdigest()
        return "%s%s" % (sig, sid)
489105
def del_password(name):
    '''
    
    '''
    cmd = 'passwd -d {0}'.format(name)
    __salt__['cmd.run'](cmd, python_shell=False, output_loglevel='quiet')
    uinfo = info(name)
    return not uinfo['passwd']
733601
function secretKey(length, options = {}) {
  if (!length || length < 1) {
    return '';
  }

  if (!options.crypto || typeof options.crypto.randomBytes !== 'function') {
    throw new Error('Expecting options.crypto to have a randomBytes function');
  }

  return options.crypto
    .randomBytes(length)
    .toString('base64') // convert format
    .slice(0, length); // return required number of characters
}
1070892
def normalize_string_keys(old):
    """"""
    new = {}
    for key, value in old.items():
        if isinstance(key, bytes_):
            new[key.decode('utf8')] = value
        else:
            new[key] = value
    return new
1346884
def generate_secret_key():
    """"""
    import string
    import random

    rng = random.SystemRandom()
    return ''.join(
        rng.choice(string.ascii_letters + string.digits)
        for dummy in range(0, 256)
    )
164131
def _create_secret(self, length=12):
        
        # Charset will have 64 +- characters
        charset = string.digits + string.ascii_letters + '+-'
        return "".join(random.SystemRandom().choice(charset) for _ in
                range(length))