示例#1
0
    def test_DecodeShouldDecryptGivenEncodedString(self):
        stringEncoder = StringCoder(self.key)
        encodedString = stringEncoder.encode(self.rawString)

        stringDecoder = StringCoder(self.key)
        decodedString = stringDecoder.decode(encodedString)

        assert decodedString == self.rawString
示例#2
0
hashed_pass = object_coder.encode(password)
hashed_pass2 = object_coder.encode(password)
hashed_pass3 = object_coder.encode(password)

print(hashed_pass)
print(hashed_pass2)
print(hashed_pass3)

passwd = object_coder.decode(hashed_pass)
print(passwd)
passwd2 = object_coder.decode(hashed_pass2)
print(passwd2)

_str = 'test123456'

string_coder = StringCoder("YyxuKKj7ir9NIfbM00C2DfBeTonX7t_uIAa-Vjbyqbg=")
hashed_str = string_coder.encode(_str)
_str = string_coder.decode(hashed_str)
print(_str)

print("############## Flask bcrypt ###################")
# from flask.ext.bcrypt import Bcrypt #deprecated
from flask_bcrypt import Bcrypt
user_name = 'testuser'
user_pass = '******'

dbClient = MongoClient('localhost', 27017)
db = dbClient.test_database
collection = db.users

示例#3
0
    def test_EncodeShouldEncryptGivenString(self):
        stringCoder = StringCoder(self.key)
        encodedString = stringCoder.encode(self.rawString)

        assert encodedString != None
        assert encodedString.strip() != ""