     case FailedURL
     case InvalidId
     case InvalidAlphabetCharacter
+    case InvalidChecksum
 }
 
 class Shortener {
     static let alphabet: [Character] = Array("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".characters)
 
     static func generateSlug(fromSeq seq: Int64) throws -> String {
-        let short = intToAlphabet(int: seq, alphabet: alphabet)
-        return short
+        let alphabetEncoded = intToAlphabet(int: seq, alphabet: alphabet)
+        let checksum = checksumForSeq(seq)
+        return checksum + alphabetEncoded
     }
 
     static func urlForSlug(_ slug: String) throws -> NSURL {

            throw ShortenerError.InvalidAlphabetCharacter
        }
    }
}


    static func seqForSlug(_ slug: String) throws -> Int64 {
        let slugChars = Array(slug.characters)
        let checksum = String(slugChars.prefix(upTo: 2))
        let encodedSeq = slugChars.suffix(from: 2)

        let intValue = try encodedSeq.map({ letter in
            return try intFromAlphabetLetter(letter)
        }).reduce(Int64(0), combine: +)

        let checksumFromDecoding = checksumForSeq(intValue)
        
        if checksum == checksumFromDecoding {
            return intValue
        } else {
            throw ShortenerError.InvalidChecksum
        }
    }

    static func intFromAlphabetLetter(_ letter: Character) throws -> Int {
