generate a credential string
974266
function getCredential(accessKey, region, requestDate) {
  if (!isString(accessKey)) {
    throw new TypeError('accessKey should be of type "string"')
  }
  if (!isString(region)) {
    throw new TypeError('region should be of type "string"')
  }
  if (!isObject(requestDate)) {
    throw new TypeError('requestDate should be of type "object"')
  }
  return `${accessKey}/${getScope(region, requestDate)}`
}
1044262
def create_credentials(credentials_file=None,
                       service_email=None,
                       service_key=None,
                       scope='https://www.googleapis.com/auth/androidpublisher'):
    
    credentials = None
    if service_email is None and service_key is None:
        print(credentials_file)
        if credentials_file is None:
            # try load file from env
            key = 'PLAY_DELIVER_CREDENTIALS'
            if key in os.environ:
                credentials_file = os.environ[key]

        if credentials_file is None:
            # try to find the file in home
            path = os.path.expanduser('~/.playdeliver/credentials.json')
            if os.path.exists(path):
                credentials_file = path

        if credentials_file is not None:
            credentials = client.GoogleCredentials.from_stream(
                credentials_file)
            credentials = credentials.create_scoped(scope)
        else:
            sys.exit("no credentials")
    else:
        credentials = client.SignedJwtAssertionCredentials(
            service_email, _load_key(service_key), scope=scope)
    return credentials
992813
def submit_string(self):
        """"""
        required = []
        optional = []
        for file_verifier in self.file_verifiers:
            if file_verifier.optional:
                optional.append('[{0}]'.format(file_verifier.filename))
            else:
                required.append(file_verifier.filename)
        return ' '.join(sorted(required) + sorted(optional))
295467
public function credential()
    {
        if (!$username = $this->username()) {
            return '';
        }
        $credentials = $username;
        if ($password = $this->password()) {
            $credentials .= ':' . $password;
        }
        return $credentials;
    }
1028143
def generate_signature(method, version, endpoint,
                       date, rel_url, content_type, content,
                       access_key, secret_key, hash_type):
    '''
    
    '''
    hash_type = hash_type
    hostname = endpoint._val.netloc  # FIXME: migrate to public API
    if version >= 'v4.20181215':
        content = b''
    else:
        if content_type.startswith('multipart/'):
            content = b''
    body_hash = hashlib.new(hash_type, content).hexdigest()

    sign_str = '{}\n{}\n{}\nhost:{}\ncontent-type:{}\nx-backendai-version:{}\n{}'.format(  # noqa
        method.upper(),
        rel_url,
        date.isoformat(),
        hostname,
        content_type.lower(),
        version,
        body_hash
    )
    sign_bytes = sign_str.encode()

    sign_key = hmac.new(secret_key.encode(),
                        date.strftime('%Y%m%d').encode(), hash_type).digest()
    sign_key = hmac.new(sign_key, hostname.encode(), hash_type).digest()

    signature = hmac.new(sign_key, sign_bytes, hash_type).hexdigest()
    headers = {
        'Authorization': 'BackendAI signMethod=HMAC-{}, credential={}:{}'.format(
            hash_type.upper(),
            access_key,
            signature
        ),
    }
    return headers, signature
1281965
def _makeCredentials(email, path, workbench):
    
    splash = _Splash(u"SSL credential generation",
                     u"Generating SSL credentials. (This can take a while.)")
    workbench.display(splash)

    makeCredentials(path, email)

    workbench.undisplay()
61289
def cli(env, identifier):
    """"""

    mgr = SoftLayer.ObjectStorageManager(env.client)
    credential = mgr.create_credential(identifier)
    table = formatting.Table(['id', 'password', 'username', 'type_name'])
    table.sortby = 'id'
    table.add_row([
        credential['id'],
        credential['password'],
        credential['username'],
        credential['type']['name']
    ])

    env.fout(table)
1172195
def _authenticate_plain(credentials, sock_info):
    
    source = credentials.source
    username = credentials.username
    password = credentials.password
    payload = ('\x00%s\x00%s' % (username, password)).encode('utf-8')
    cmd = SON([('saslStart', 1),
               ('mechanism', 'PLAIN'),
               ('payload', Binary(payload)),
               ('autoAuthorize', 1)])
    sock_info.command(source, cmd)
1214526
def add_credential(self, url, username, password):
        
        cur = self.conn.cursor()

        cur.execute("SELECT * FROM credentials WHERE LOWER(username)=LOWER(?) AND password=?", [url, username, password])
        results = cur.fetchall()

        if not len(results):
            cur.execute("INSERT INTO credentials (username, password) VALUES (?,?)", [username, password] )

        cur.close()
1181665
public Credential generateCredential() throws OAuthException {
    GoogleCredential credential = Strings.isNullOrEmpty(this.jsonKeyFilePath)
        ? generateCredentialFromClientSecrets()
        : generateCredentialFromKeyFile();
    try {
      if (!oAuth2Helper.callRefreshToken(credential)) {
        throw new OAuthException(
            "Credential could not be refreshed. A newly generated refresh token or "
            + "secret key may be required.");
      }
    } catch (IOException e) {
      throw new OAuthException("Credential could not be refreshed.", e);
    }
    return credential;
  }
307067
def generate_uuid():
    """"""
    r_uuid = base64.urlsafe_b64encode(uuid.uuid4().bytes)
    return r_uuid.decode().replace('=', '')
1103033
public function generateSignature()
    {
        $signatureArray = array();

        // Create a pre-hash string based on the security credentials
        // The order is important
        foreach ($this->validSecurityKeys as $key) {
            if (array_key_exists($key, $this->securityPacket)) {
                array_push($signatureArray, $this->securityPacket[$key]);
            }
        }

        // Add the secret
        array_push($signatureArray, $this->secret);

        // Add the requestPacket if necessary
        if ($this->signRequestData && !empty($this->requestString)) {
            array_push($signatureArray, $this->requestString);
        }

        // Add the action if necessary
        if (!empty($this->action)) {
            array_push($signatureArray, $this->action);
        }

        return $this->hashValue($signatureArray);
    }
1367563
def generate_edit_credentials(self):
        
        params = {
            'action': 'query',
            'meta': 'tokens',
            'format': 'json'
        }
        response = self.s.get(self.base_url, params=params)
        self.edit_token = response.json()['query']['tokens']['csrftoken']

        return self.s.cookies
1157341
public Credentials toCredentials(String username, String password) {
	return CredentialsImpl.toCredentials(username, password);
    }
373865
def generate_password(length=16):
    
    chars = string.ascii_letters + string.digits + '!@#$%^&*()_+-=[]{};:,<.>?|'
    modulus = len(chars)
    pchars = os.urandom(16)
    if type(pchars) == str:
        return ''.join(chars[i % modulus] for i in map(ord, pchars))
    else:
        return ''.join(chars[i % modulus] for i in pchars)
1325747
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'credential_type' in _dict:
            args['credential_type'] = _dict.get('credential_type')
        if 'client_id' in _dict:
            args['client_id'] = _dict.get('client_id')
        if 'enterprise_id' in _dict:
            args['enterprise_id'] = _dict.get('enterprise_id')
        if 'url' in _dict:
            args['url'] = _dict.get('url')
        if 'username' in _dict:
            args['username'] = _dict.get('username')
        if 'organization_url' in _dict:
            args['organization_url'] = _dict.get('organization_url')
        if 'site_collection.path' in _dict:
            args['site_collection_path'] = _dict.get('site_collection.path')
        if 'client_secret' in _dict:
            args['client_secret'] = _dict.get('client_secret')
        if 'public_key_id' in _dict:
            args['public_key_id'] = _dict.get('public_key_id')
        if 'private_key' in _dict:
            args['private_key'] = _dict.get('private_key')
        if 'passphrase' in _dict:
            args['passphrase'] = _dict.get('passphrase')
        if 'password' in _dict:
            args['password'] = _dict.get('password')
        if 'gateway_id' in _dict:
            args['gateway_id'] = _dict.get('gateway_id')
        if 'source_version' in _dict:
            args['source_version'] = _dict.get('source_version')
        if 'web_application_url' in _dict:
            args['web_application_url'] = _dict.get('web_application_url')
        if 'domain' in _dict:
            args['domain'] = _dict.get('domain')
        if 'endpoint' in _dict:
            args['endpoint'] = _dict.get('endpoint')
        if 'access_key_id' in _dict:
            args['access_key_id'] = _dict.get('access_key_id')
        if 'secret_access_key' in _dict:
            args['secret_access_key'] = _dict.get('secret_access_key')
        return cls(**args)
1004533
def from_connection_string(s):
		
		cred = KerberosCredential()
		
		cred.domain, t = s.split('/', 1)
		cred.username, t = t.split('/', 1)
		secret_type, t = t.split(':', 1)
		secret, target = t.rsplit('@', 1)
		
		st = KerberosSecretType(secret_type.upper())
		if st == KerberosSecretType.PASSWORD or st == KerberosSecretType.PW or st == KerberosSecretType.PASS:
			cred.password = secret
		
		elif st == KerberosSecretType.NT or st == KerberosSecretType.RC4:
			cred.nt_hash = secret
			cred.kerberos_key_rc4 = secret
			
		
		elif st == KerberosSecretType.AES:
			cred.kerberos_key_aes_256 = secret
			cred.kerberos_key_aes_128 = secret
		
		elif st == KerberosSecretType.DES:
			cred.kerberos_key_des = secret
		
		elif st == KerberosSecretType.DES3 or st == KerberosSecretType.TDES:
			cred.kerberos_key_des3 = secret
			
		elif st == KerberosSecretType.CCACHE:
			cred.ccache = CCACHE.from_file(secret)
			
		return cred