Will update a single key in a generic secret backend as
    thought it were a password
559460
def update_generic_password(client, path):
    """"""
    vault_path, key = path_pieces(path)
    mount = mount_for_path(vault_path, client)
    if not mount:
        client.revoke_self_token()
        raise aomi.exceptions.VaultConstraint('invalid path')

    if backend_type(mount, client) != 'generic':
        client.revoke_self_token()
        raise aomi.exceptions.AomiData("Unsupported backend type")

    LOG.debug("Updating generic password at %s", path)
    existing = client.read(vault_path)
    if not existing or 'data' not in existing:
        LOG.debug("Nothing exists yet at %s!", vault_path)
        existing = {}
    else:
        LOG.debug("Updating %s at %s", key, vault_path)
        existing = existing['data']

    new_password = get_password()
    if key in existing and existing[key] == new_password:
        client.revoke_self_token()
        raise aomi.exceptions.AomiData("Password is same as existing")

    existing[key] = new_password
    client.write(vault_path, **existing)
1076029
def _update_keycache(self, *args, forward):
        """"""
        entity, key, branch, turn, tick, value = args[-6:]
        parent = args[:-6]
        kc = self._get_keycache(parent + (entity,), branch, turn, tick, forward=forward)
        if value is None:
            kc = kc.difference((key,))
        else:
            kc = kc.union((key,))
        self.keycache[parent+(entity, branch)][turn][tick] = kc
229129
def unserialize(cls, string, secret_key):
        
        if isinstance(string, text_type):
            string = string.encode('utf-8', 'replace')
        if isinstance(secret_key, text_type):
            secret_key = secret_key.encode('utf-8', 'replace')
        try:
            base64_hash, data = string.split(b'?', 1)
        except (ValueError, IndexError):
            items = ()
        else:
            items = {}
            mac = hmac(secret_key, None, cls.hash_method)
            for item in data.split(b'&'):
                mac.update(b'|' + item)
                if not b'=' in item:
                    items = None
                    break
                key, value = item.split(b'=', 1)
                # try to make the key a string
                key = url_unquote_plus(key.decode('ascii'))
                try:
                    key = to_native(key)
                except UnicodeError:
                    pass
                items[key] = value

            # no parsing error and the mac looks okay, we can now
            # sercurely unpickle our cookie.
            try:
                client_hash = base64.b64decode(base64_hash)
            except TypeError:
                items = client_hash = None
            if items is not None and safe_str_cmp(client_hash, mac.digest()):
                try:
                    for key, value in iteritems(items):
                        items[key] = cls.unquote(value)
                except UnquoteError:
                    items = ()
                else:
                    if '_expires' in items:
                        if time() > items['_expires']:
                            items = ()
                        else:
                            del items['_expires']
            else:
                items = ()
        return cls(items, secret_key, False)
1134892
def cli(ctx, id_number, new_key, metadata=""):
    
    return ctx.gi.cannedkeys.update_key(id_number, new_key, metadata=metadata)
97645
def update(self):
        
        error = ""

        if self.key is None:
            error = "To update a client you need to provide a key"
        if self.secret is None:
            error = "To update a client you need to provide the secret"

        if error:
            raise ClientException(error)

        self.request()
        return True
292374
function getEncryptionKey (key) {
  key = key || process.env.ENCRYPTION_KEY
  if (!key) throw new Error('encryption key not found')

  const cryptoKey = crypto.createHash('sha256').update(key).digest()
  return cryptoKey
}
323371
function(key, updates) {
      var that = this;

      if (!this._key || !key) {
        return Promise.reject(new Error('No unique key specified'));
      }

      return this.readByKey(key).then(function(doc) {
        return that._updateDoc(doc, updates);
      });
    }
776194
def add_key(pub):
    """"""
    global _server_keys
    key = rsa.PublicKey.load_pkcs1(pub)
    _server_keys[_compute_fingerprint(key)] = key
65716
function otpauth(key, name) {
  var code = 'otpauth://totp/' + encodeURIComponent(name);
  code += '?secret=' + encodeURIComponent(key);
  code += '&issuer=' + encodeURIComponent('One Sony');
  return code;
}
810923
def _update_secret(namespace, name, data, apiserver_url):
    ''''''
    # Prepare URL
    url = "{0}/api/v1/namespaces/{1}/secrets/{2}".format(apiserver_url,
                                                         namespace, name)
    # Prepare data
    data = [{"op": "replace", "path": "/data", "value": data}]
    # Make request
    ret = _kpatch(url, data)
    if ret.get("status") == 404:
        return "Node {0} doesn't exist".format(url)
    return ret
840747
def attemptByKey(self, key):
        

        return self.store.findUnique(_PasswordResetAttempt,
                                     _PasswordResetAttempt.key == key,
                                     default=None)
752059
function expectAliClaimKeys() {
    return bobTestClient.awaitOneTimeKeyUpload().then((keys) => {
        aliTestClient.httpBackend.when(
            "POST", "/keys/claim",
        ).respond(200, function(path, content) {
            const claimType = content.one_time_keys[bobUserId][bobDeviceId];
            expect(claimType).toEqual("signed_curve25519");
            let keyId = null;
            for (keyId in keys) {
                if (bobTestClient.oneTimeKeys.hasOwnProperty(keyId)) {
                    if (keyId.indexOf(claimType + ":") === 0) {
                        break;
                    }
                }
            }
            const result = {};
            result[bobUserId] = {};
            result[bobUserId][bobDeviceId] = {};
            result[bobUserId][bobDeviceId][keyId] = keys[keyId];
            return {one_time_keys: result};
        });
    }).then(() => {
        // it can take a while to process the key query, so give it some extra
        // time, and make sure the claim actually happens rather than ploughing on
        // confusingly.
        return aliTestClient.httpBackend.flush("/keys/claim", 1, 500).then((r) => {
            expect(r).toEqual(1, "Ali did not claim Bob's keys");
        });
    });
}
958423
def create_key(self):
        """"""
        print("Creating key. Please input the following options:")
        name = input("Key name (optional): ")
        print("To make this key more secure, you should restrict the IP addresses that can use it. ")
        print("To use with all IPs, leave blank or use 0.0.0.0/0.")
        print("To use with a single IP, append '/32', such as 207.39.29.22/32. ")
        print("See this reference on CIDR blocks: http://software77.net/cidr-101.html")
        cidr = input("CIDR (optional): ")
        key = self._curl_bitmex("/apiKey",
                                postdict={"name": name, "cidr": cidr, "enabled": True})

        print("Key created. Details:\n")
        print("API Key:    " + key["id"])
        print("Secret:     " + key["secret"])
        print("\nSafeguard your secret key! If somebody gets a hold of your API key and secret,")
        print("your account can be taken over completely.")
        print("\nKey generation complete.")
1110890
function OAuthToken( key, secret ){
    if( ! key || ! secret ){
        throw new Error('OAuthToken params must not be empty');
    }
    this.key = key;
    this.secret = secret;
}
1014366
def update_security_of_password(self, ID, data):
        """"""
        # http://teampasswordmanager.com/docs/api-passwords/#update_security_password
        log.info('Update security of password %s with %s' % (ID, data))
        self.put('passwords/%s/security.json' % ID, data)
69558
function expectAliQueryKeys() {
    // can't query keys before bob has uploaded them
    expect(bobTestClient.deviceKeys).toBeTruthy();

    const bobKeys = {};
    bobKeys[bobDeviceId] = bobTestClient.deviceKeys;
    aliTestClient.httpBackend.when("POST", "/keys/query")
            .respond(200, function(path, content) {
        expect(content.device_keys[bobUserId]).toEqual(
            {},
            "Expected Alice to key query for " + bobUserId + ", got " +
            Object.keys(content.device_keys),
        );
        const result = {};
        result[bobUserId] = bobKeys;
        return {device_keys: result};
    });
    return aliTestClient.httpBackend.flush("/keys/query", 1);
}
866384
def update_and_reencrypt(self, **kwargs):
        
        encrypted_field_name = self.store.model_class.__plaintext__

        id_ = kwargs[self.identifier_key]
        current_model = self.store.retrieve(id_)
        current_value = current_model.plaintext

        null_update = (
            # Check if the update is for the encrypted field, and if it's explicitly set to null
            encrypted_field_name in kwargs
            and kwargs.get(encrypted_field_name) is None
        )
        new_value = kwargs.pop(self.store.model_class.__plaintext__, None)
        use_new_value = new_value is not None or null_update

        updated_value = new_value if use_new_value else current_value

        model_kwargs = {
            self.identifier_key: id_,
            encrypted_field_name: updated_value,
            **kwargs,
        }

        return super().update(
            **model_kwargs,
        )