Please, for the love of all that is good in this world, do not use this for cryptography. Except the cryptography class. Let's all use this for the cryptography class.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

45 lines
940 B

from flask import Flask, render_template, jsonify
import sys
import entropy
app = Flask(__name__)
e = entropy.EntropyPipe()
@app.route('/')
def root():
return render_template('index.html')
@app.route('/bits')
def bits():
return render_template('bitpage.html')
@app.route('/api/one', methods=["GET"])
def one():
e.add_entropy([True])
return render_template('bitpage.html')
@app.route('/api/zero', methods=["GET"])
def zero():
e.add_entropy([False])
return render_template('bitpage.html')
@app.route('/api/randbit', methods=["GET"])
def randbit():
try:
bit = e.invoke_entropy(1)[0]
return jsonify({
"bit" : str(ord(bit))
})
except IndexError:
return jsonify({
"bit" : "Entropy machine broke"
})
if __name__ == '__main__':
if len(sys.argv) == 2:
port = sys.argv[1]
else:
port = 5000
app.run(port=port)