new_contents: # -*- coding: utf-8 -*-
  import math
  from zlib import crc32
  from django.contrib.sites.shortcuts import get_current_site
  
  BASE = 62
  
  UPPERCASE_OFFSET = 55
  LOWERCASE_OFFSET = 61
  DIGIT_OFFSET = 48
  
  
  def true_ord(char):
      """
      Turns a digit [char] in character representation
      from the number system with base [BASE] into an integer.
      """
  
      if char.isdigit():
          return ord(char) - DIGIT_OFFSET
      elif 'A' <= char <= 'Z':
          return ord(char) - UPPERCASE_OFFSET
      elif 'a' <= char <= 'z':
          return ord(char) - LOWERCASE_OFFSET
      else:
          raise ValueError("%s is not a valid character" % char)
  
  
  def true_chr(integer):
      """
      Turns an integer [integer] into digit in base [BASE]
      as a character representation.
      """
      if integer < 10:
          return chr(integer + DIGIT_OFFSET)
      elif 10 <= integer <= 35:
          return chr(integer + UPPERCASE_OFFSET)
      elif 36 <= integer < 62:
          return chr(integer + LOWERCASE_OFFSET)
      else:
          raise ValueError("%d is not a valid integer in the range of base %d" % (integer, BASE))
  
  
  def saturate(key):
      """
      Turn the base [BASE] number [key] into an integer
      """
      int_sum = 0
      reversed_key = key[::-1]
      for idx, char in enumerate(reversed_key):
          int_sum += true_ord(char) * int(math.pow(BASE, idx))
      return int_sum
  
  
  def dehydrate(integer):
      """
      Turn an integer [integer] into a base [BASE] number
      in string representation
      """
  
      # we won't step into the while if integer is 0
      # so we just solve for that case here
      if integer == 0:
          return '0'
  
      string = ""
      while integer > 0:
          remainder = integer % BASE
          string = true_chr(remainder) + string
          integer /= BASE
      return string
  
  
  def create_full_shorturl(request, short_url):
      """
      Return the full short url
      :return:
      """
      if request.is_secure():
          prefix = 'https://%s/%s'
      else:
          prefix = 'http://%s/%s'
  
      return prefix % (get_current_site(request), short_url)
subject: Add shorting algorithm.