Пример #1
0
def hashPass(plainPass, username):
	#hash password through sha512 with 1 million rounds.
	#static salt of 20 random characters, dynamic salt of the username
	staticSalt = "r!6bCZ&2e7a28d6dfE0c"
	shaHasher = Hashing()
	h = shaHasher.hash_value(plainPass, salt=username+staticSalt)
	return h
Пример #2
0
class MyTest(unittest.TestCase):
    def setUp(self):
        self.app = Flask(__name__)
        self.app.config['HASHING_METHOD'] = 'sha256'
        self.h = Hashing(self.app)

    def test_hash_capability(self):
        val = 'somethingsecret'
        salt = 'abcd'
        valhash = self.h.hash_value(val, salt)
        self.assertTrue(self.h.check_value(valhash, val, salt))
        self.assertFalse(self.h.check_value(valhash, val, 'efgh'))
        self.assertFalse(self.h.check_value(valhash, val+'poop', salt))

    def test_multiple_rounds(self):
        self.app.config['HASHING_ROUNDS'] = 5
        self.h = Hashing(self.app)
        self.test_hash_capability()

    def test_different_algorithm(self):
        self.app.config['HASHING_METHOD'] = 'md5'
        self.h = Hashing(self.app)
        self.test_hash_capability()

    def test_rounds_not_int(self):
        self.app.config['HASHING_ROUNDS'] = 'notanint'
        self.assertRaises(TypeError, Hashing().init_app, self.app)
        self.app.config['HASHING_ROUNDS'] = 1

    def test_algorithm_not_valid(self):
        self.app.config['HASHING_METHOD'] = 'notahashalgorithm'
        self.assertRaises(ValueError, Hashing().init_app, self.app)
Пример #3
0
from flask import Flask, render_template, request, redirect, url_for
from flask import session, flash
from flask import jsonify
import os, sys
from functools import wraps
import MySQLdb
from flask.ext.hashing import Hashing
import socket, threading, time
from threading import Lock

#create app object
app = Flask(__name__)

#hashing lines from hello3
#bcrypt = Bcrypt(app)
hashgun = Hashing(app)
# config
app.secret_key = os.urandom(11)

# host and port for the socket
host = '0.0.0.0'
port = 10000

#Open db connection
db = MySQLdb.connect("localhost", "SGDAdmin", "password", "WEBAPP")

#prepare cursor object
cursor = db.cursor()

#execute SQL query
cursor.execute("SELECT VERSION()")
Пример #4
0
import os

from flask.ext.script import Manager, Command
from flask.ext.hashing import Hashing

from stacktracker import app

try:
    input = raw_input
except NameError:
    pass
manager = Manager(app)
hashing = Hashing(app)


@manager.command
def initdb():
    """Initializes an empty application database"""
    from stacktracker import db
    db.create_all()


@manager.command
def dumpconfig():
    """Dumps the application's current config"""
    from pprint import pprint
    pprint(app.config)


@manager.command
def admin(email):
Пример #5
0
 def setUp(self):
     self.app = Flask(__name__)
     self.app.config['HASHING_METHOD'] = 'sha256'
     self.h = Hashing(self.app)
Пример #6
0
 def test_different_algorithm(self):
     self.app.config['HASHING_METHOD'] = 'md5'
     self.h = Hashing(self.app)
     self.test_hash_capability()
Пример #7
0
 def test_multiple_rounds(self):
     self.app.config['HASHING_ROUNDS'] = 5
     self.h = Hashing(self.app)
     self.test_hash_capability()