import string
import random


def randomstring(strlen=12, prefix=''):
  """
  Generate a random string from the set of ascii letters and
  decimal digits.

  Parameters:
    strlen    Length of generated string including prefix.
    prefix    Prefix string to random string.

  Returns:
    String.
  """
  n = strlen - len(prefix)
  if n <= 0:
    return prefix[:strlen]
  src = string.ascii_letters + string.digits
  return prefix + ''.join(random.choice(src) for i in range(n))