Create a contender key
351356
def contender_key(value = 'none')
      if value.nil? || value.empty?
        raise ArgumentError, 'Value cannot be empty or nil'
      end
      key = "#{prefix}/#{session.id}"
      ::DaemonRunner::RetryErrors.retry do
        @contender_key = Diplomat::Lock.acquire(key, session.id, value)
      end
      @contender_key
    end
732232
def _key(self, username, frozen=False):
        """"""
        if frozen:
            return self.frozen + username
        return self.prefix + username
538229
async function challengeCreateFn(authz, challenge, keyAuthorization) {
    /* Do something here */
    log(JSON.stringify(authz));
    log(JSON.stringify(challenge));
    log(keyAuthorization);
}
1335520
def accept_key(pki_dir, pub, id_):
    '''
    
    '''
    for key_dir in 'minions', 'minions_pre', 'minions_rejected':
        key_path = os.path.join(pki_dir, key_dir)
        if not os.path.exists(key_path):
            os.makedirs(key_path)

    key = os.path.join(pki_dir, 'minions', id_)
    with salt.utils.files.fopen(key, 'w+') as fp_:
        fp_.write(salt.utils.stringutils.to_str(pub))

    oldkey = os.path.join(pki_dir, 'minions_pre', id_)
    if os.path.isfile(oldkey):
        with salt.utils.files.fopen(oldkey) as fp_:
            if fp_.read() == pub:
                os.remove(oldkey)
264028
def create_ssh_pub_key(self, name, key):
        
        self.nova.keypairs.create(name, key)
175787
def create_keypair(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        log.error(
            'The create_keypair function must be called with -f or --function.'
        )
        return False

    if not kwargs:
        kwargs = {}

    if 'keyname' not in kwargs:
        log.error('A keyname is required.')
        return False

    params = {'Action': 'CreateKeyPair',
              'KeyName': kwargs['keyname']}

    data = aws.query(params,
                     return_url=True,
                     return_root=True,
                     location=get_location(),
                     provider=get_provider(),
                     opts=__opts__,
                     sigver='4')
    keys = [x for x in data[0] if 'requestId' not in x]

    return (keys, data[1])
998805
def key(username, key, all):
    """"""
    if username and username not in current_app.config['ADMIN_USERS']:
        raise click.UsageError('User {} not an admin'.format(username))

    def create_key(admin, key):
        key = ApiKey(
            user=admin,
            key=key,
            scopes=[Scope.admin, Scope.write, Scope.read],
            text='Admin key created by alertad script',
            expire_time=None
        )
        try:
            db.get_db()  # init db on global app context
            key = key.create()
        except Exception as e:
            click.echo('ERROR: {}'.format(e))
        else:
            click.echo('{} {}'.format(key.key, key.user))

    if all:
        for admin in current_app.config['ADMIN_USERS']:
            create_key(admin, key)
    elif username:
        create_key(username, key)
    else:
        raise click.UsageError("Must set '--username' or use '--all'")
1123787
def update_or_create_candidate(
        self, candidate, aggregable=True, uncontested=False
    ):
        """"""
        candidate_election, c = CandidateElection.objects.update_or_create(
            candidate=candidate,
            election=self,
            defaults={"aggregable": aggregable, "uncontested": uncontested},
        )

        return candidate_election
913186
def create_ikepolicy(self, name, **kwargs):
        '''
        
        '''
        body = {'name': name}
        if 'phase1_negotiation_mode' in kwargs:
            body['phase1_negotiation_mode'] = kwargs['phase1_negotiation_mode']
        if 'auth_algorithm' in kwargs:
            body['auth_algorithm'] = kwargs['auth_algorithm']
        if 'encryption_algorithm' in kwargs:
            body['encryption_algorithm'] = kwargs['encryption_algorithm']
        if 'pfs' in kwargs:
            body['pfs'] = kwargs['pfs']
        if 'ike_version' in kwargs:
            body['ike_version'] = kwargs['ike_version']
        if 'units' in kwargs:
            body['lifetime'] = {'units': kwargs['units']}
        if 'value' in kwargs:
            if 'lifetime' not in body:
                body['lifetime'] = {}
            body['lifetime']['value'] = kwargs['value']
        return self.network_conn.create_ikepolicy(body={'ikepolicy': body})
318829
def challenge_record_valid?(domain, key)
      record = challenge_record(domain)
      return record && record.data == key
    end
998902
public static <K, V> Entry<K, V> hp(K key, V value) {
    return new ComparableEntry<>(key, value);
  }
178541
function expandKey(key) {
	let tempWord = new Array(WORD_LENGTH);
	let rounds = getRoundsCount(key);
	let wordsCount = key.length / WORD_LENGTH;
	let keySchedule = new Array(COLUMNS * (rounds + 1));
	
	for (let i = 0; i < wordsCount; i++) {
		keySchedule[i] = key.slice(WORD_LENGTH * i, WORD_LENGTH * i + WORD_LENGTH);
	}
	for (let i = wordsCount; i < keySchedule.length; i++) {
		tempWord = keySchedule[i - 1];
		if (i % wordsCount === 0) {
			tempWord = a_u.xorWords(a_u.subWord(a_u.rotWordLeft(tempWord)), a_u.R_CON[i / wordsCount]);
		} else if (wordsCount > 6 && i % wordsCount === 4) {
			tempWord = a_u.subWord(tempWord);
		}
		keySchedule[i] = a_u.xorWords(keySchedule[i - wordsCount], tempWord);
	}
	return keySchedule;
}
677624
def make_key(self, value):
        
        if value:
            parts = [self.key_filter.sub('', x)
                     for x in self.key_split.split(value.lower())]
            key = parts[0] + ''.join(map(str.capitalize, parts[1:]))
        else:
            key = ''
        if key in self.seen_keys:
            i = 1
            while '%s%d' % (key, i) in self.seen_keys:
                i += 1
            key = '%s%d' % (key, i)
        self.seen_keys.add(key)
        return key
680589
def make_key
      if options.key? :method
        options[:method].to_sym
      elsif options.include?(:controller) && options.include?(:action)
        "#{options[:controller]}_#{options[:action]}".to_sym
      else
        raise(ArgumentError,
              'Options should contain :controller and :action or :method.')
      end
    end
376453
public void setupKeys()
    {
        KeyAreaInfo keyArea = null;
        keyArea = new KeyAreaInfo(this, Constants.UNIQUE, ID_KEY);
        keyArea.addKeyField(ID, Constants.ASCENDING);
        keyArea = new KeyAreaInfo(this, Constants.NOT_UNIQUE, ISSUE_ID_KEY);
        keyArea.addKeyField(ISSUE_ID, Constants.ASCENDING);
    }
1017318
async function challengeCreateFn(authz, challenge, keyAuthorization) {
    log('Triggered challengeCreateFn()');

    /* http-01 */
    if (challenge.type === 'http-01') {
        const filePath = `/var/www/html/.well-known/acme-challenge/${challenge.token}`;
        const fileContents = keyAuthorization;

        log(`Creating challenge response for ${authz.identifier.value} at path: ${filePath}`);

        /* Replace this */
        log(`Would write "${fileContents}" to path "${filePath}"`);
        // await fs.writeFile(filePath, fileContents);
    }

    /* dns-01 */
    else if (challenge.type === 'dns-01') {
        const dnsRecord = `_acme-challenge.${authz.identifier.value}`;
        const recordValue = keyAuthorization;

        log(`Creating TXT record for ${authz.identifier.value}: ${dnsRecord}`);

        /* Replace this */
        log(`Would create TXT record "${dnsRecord}" with value "${recordValue}"`);
        // await cloudflare.createRecord(dnsRecord, 'TXT', recordValue);
    }
}
1271223
def create_key(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        log.error(
            'The create_key function must be called with -f or --function.'
        )
        return False

    try:
        result = query(
            method='account',
            command='keys',
            args={'name': kwargs['name'],
                  'public_key': kwargs['public_key']},
            http_method='post'
        )
    except KeyError:
        log.info('`name` and `public_key` arguments must be specified')
        return False

    return result