Exemplo n.º 1
0
def show_post():
    """Return the random URL after posting the plaintext."""
    new_url = request.form["new_url"]
    note = Note(new_url)
    note.plaintext = request.form['paste']

    passphrase = request.form.get('pass', False)
    duress = request.form.get('duress', False)
    token = request.form['hashcash']

    if not utils.verify_hashcash(token):
        return redirect(url_for('index', error='hashcash'))
    if duress and not passphrase:
        return redirect(url_for('index', error='duress'))

    if passphrase:
        note.set_passphrase(passphrase)
        note.encrypt()
        if duress:
            note.duress_key()
            return render_template('post.html',
                                   random=note.url,
                                   passphrase=note.passphrase,
                                   duress=note.dkey)
        return render_template('post.html',
                               random=note.url,
                               passphrase=note.passphrase)
    else:
        note.encrypt()
        return render_template('post.html', random=note.url)
Exemplo n.º 2
0
def show_post():
    """Return the random URL after posting the plaintext."""
    new_url = request.form["new_url"]
    note = Note(new_url)
    note.plaintext = request.form['paste']

    passphrase = request.form.get('pass', False)
    token = request.form['hashcash']

    if not utils.verify_hashcash(token):
        return redirect(url_for('index', error='hashcash'))

    if passphrase:
        note.set_passphrase(passphrase)
        note.encrypt()
        note.duress_key()
        return render_template('post.html', random=note.url,
                               passphrase=note.passphrase, duress=note.dkey)
    else:
        note.encrypt()
        return render_template('post.html', random=note.url)
Exemplo n.º 3
0
def show_post():
    """Return the random URL after posting the plaintext."""
    # Generate URL server-side    
    min_char = 16
    max_char = 25
    allchar = string.ascii_letters + string.digits
    new_url = "".join(random.SystemRandom().choice(allchar) for x in range(random.randint(min_char, max_char)))

    # Create Note object
    note = Note(new_url)

    # Check to avoid overwriting existing Note, regenerate if necessary - sorry hardcoded data_dir path for now
    data_dir = "/var/lib/dnote/data/"
    pathFilename = data_dir + note.fname
    while os.path.isfile(pathFilename):
       new_url = "".join(random.SystemRandom().choice(allchar) for x in range(random.randint(min_char, max_char)))
       note = Note(new_url)
       pathFilename = data_dir + note.fname

    note.plaintext = request.form['paste']

    passphrase = request.form.get('pass', False)
    token = request.form['hashcash']

    if not utils.verify_hashcash(token):
        return redirect(url_for('index', error='hashcash'))

    if passphrase:
        note.set_passphrase(passphrase)
        note.encrypt()
        note.duress_key()
        return render_template('post.html', random=note.url,
                               passphrase=note.passphrase, duress=note.dkey)
    else:
        note.encrypt()
        return render_template('post.html', random=note.url)