Esempio n. 1
0
File: net.py Progetto: Enerdy/bfdb
def action(action_id, body, encode_key):
    data = json.dumps({
        REQ_HEADER_TAG: {REQ_ID: action_id},
        REQ_BODY_TAG: {REQ_BODY: crypt.encode(body, encode_key)}
    }, separators=(',', ':'))

    headers = {
        'Accept': '*/*',
        'Accept-Encoding': 'gzip',
        'Accept-Language': 'en',
        'User-Agent': 'android',
        'Content-Length': len(data),
        'Content-Type': 'application/x-www-form-urlencoded',
        'Expect': '100-continue'
    }

    r = requests.post('http://iosv2.bravefrontier.gumi.sg/bf/gme/action.php',
                      headers=headers,
                      data=data)

    if r.status_code == 200:
        try:
            return crypt.decode(r.json()[REQ_BODY_TAG][REQ_BODY], encode_key)
        except:
            pass

    return None
Esempio n. 2
0
File: net.py Progetto: jdschmi1/bfdb
def action(action_id, body, encode_key):
    data = json.dumps(
        {
            REQ_HEADER_TAG: {
                REQ_ID: action_id
            },
            REQ_BODY_TAG: {
                REQ_BODY: crypt.encode(body, encode_key)
            }
        },
        separators=(',', ':'))

    headers = {
        'Accept': '*/*',
        'Accept-Encoding': 'gzip',
        'Accept-Language': 'en',
        'User-Agent': 'android',
        'Content-Length': len(data),
        'Content-Type': 'application/x-www-form-urlencoded',
        'Expect': '100-continue'
    }

    r = requests.post('http://iosv2.bravefrontier.gumi.sg/bf/gme/action.php',
                      headers=headers,
                      data=data)

    if r.status_code == 200:
        try:
            return crypt.decode(r.json()[REQ_BODY_TAG][REQ_BODY], encode_key)
        except:
            pass

    return None
Esempio n. 3
0
def final(request):
    storage = get_messages(request)
    name = None
    for message in storage:
        name = message
        break
    name = str(name)

    n = str(encode(name))
    return render(request, 'first_app/final.html', {'answer': n})
    def save_data(self):
        if not self.modified:
            return

        im = Image.open(self.prefix + self.src)
        encoded = crypt.encode(self.key, ''.join(self.data))
        enc_im = stepic.encode(im, encoded)
        enc_im.save(self.prefix + self.src)
        self.modified = False
        return
Esempio n. 5
0
def addPass(userID, name, login, password, c = None, conn = None):
    try:
        
        cryptedLogin = crypt.encode(str(userID), login)
        cryptedPass = crypt.encode(str(userID), password)
        c.execute('CREATE TABLE IF NOT EXISTS user' + str(userID) + ' (id INTEGER, name TEXT NOT NULL);')
        c.execute('INSERT INTO user' + str(userID) + ' VALUES (?, ?)', (userID, name))
        conn.commit()
        cname=crypt.getHash(name)
        clogin=cryptedLogin[0]
        cpassword=cryptedPass[0]
        lnonce=cryptedLogin[1]
        pnonce=cryptedPass[1]
        c.execute('CREATE TABLE IF NOT EXISTS u' + crypt.getHash(str(userID)) + ' (cname TEXT NOT NULL, clogin TEXT NOT NULL, cpassword TEXT NOT NULL, lnonce TEXT NOT NULL, pnonce TEXT NOT NULL);')
        c.execute('INSERT INTO u' + crypt.getHash(str(userID)) + ' VALUES (?, ?, ?, ?, ?)', (cname, clogin, cpassword, lnonce, pnonce))
        conn.commit()

        res = 'name: <b>' + name + '</b>\n-----\nlogin: <code>' + login + '</code> | password: <code>' + password + '</code>\nWas added!'
    except Exception:
        traceback.print_exc()
        res = 'Something went wrong'
    return res
Esempio n. 6
0
  def save_data(self):
    """ Saves the block data """

    if not self.modified:
      return

    im = Image.open(self.prefix+self.src)
    encoded = crypt.encode(self.key, ''.join(self.data))

    enc_im = stepic.encode(im, encoded)
    enc_im.save(self.prefix+self.src)

    self.modified = False
    return
 def format_image(self):
     print "Formatting ", self.src
     im = Image.open(self.prefix + self.src)
     data_size = im.size[0] * im.size[1] / 3
     if data_size % 16 != 0:
         data_size += data_size % crypt.block_size
         data_size -= 32
     print "Image size: (", im.size[0], ",", im.size[1], ")"
     print "Possible data inside this block:", (data_size / 1024), "Kb"
     data_size -= 32
     data = "$" * data_size
     enc_data = crypt.encode(self.key, data)
     im = stepic.encode(im, enc_data)
     im.save(self.prefix + self.src)
     return data_size
Esempio n. 8
0
 def format_image(self):
   """ Formats an image to be used in the filesystem """
   print "Formatting ", self.src
   im = Image.open(self.prefix+self.src)
   data_size = im.size[0] * im.size[1] / 3
   if data_size % 16 != 0:
     data_size += data_size % crypt.block_size
     data_size -= 32
   print "Image size: (", im.size[0], ",", im.size[1], ")"
   print "Possible data inside this block:", (data_size/1024), "Kb"
   data_size -= 32
   data = "$"*data_size
   enc_data = crypt.encode(self.key, data)
   im = stepic.encode(im, enc_data)
   im.save(self.prefix+self.src)
   return data_size
Esempio n. 9
0
 def setValue(self, key, value):
   encrypted_value = crypt.encode(self.key(), value)
   encoded_value = base64.b64encode(str(encrypted_value))
   super(CryptSettings, self).setValue(key,encoded_value)