2015-02-14 07:37:05 +00:00
|
|
|
import os
|
|
|
|
from .wordlist import byte_to_even_word, byte_to_odd_word
|
2015-02-11 02:34:13 +00:00
|
|
|
|
|
|
|
def make_code(channel_id):
|
2015-02-14 07:37:05 +00:00
|
|
|
even_word = byte_to_even_word[os.urandom(1)]
|
|
|
|
odd_word = byte_to_odd_word[os.urandom(1)]
|
|
|
|
return "%d-%s-%s" % (channel_id, even_word, odd_word)
|
2015-02-11 02:34:13 +00:00
|
|
|
|
|
|
|
def extract_channel_id(code):
|
|
|
|
channel_id = int(code.split("-")[0])
|
|
|
|
return channel_id
|