Exemple #1
0
#!/usr/bin/env python

from collections import OrderedDict
import datetime
from getpass import getpass
import sys

from peewee import *
from playhouse.sqlcipher_ext import SqlCipherDatabase

# Defer initialization of the database until the script is executed from the
# command-line.
db = SqlCipherDatabase(None)


class Entry(Model):
    content = TextField()
    timestamp = DateTimeField(default=datetime.datetime.now)

    class Meta:
        database = db


def initialize(passphrase):
    db.init('diary.db', passphrase=passphrase)
    db.create_tables([Entry])


def menu_loop():
    choice = None
    while choice != 'q':
Exemple #2
0
    pass

__version__ = '0.0.2'
path = os.getenv('HOME', os.path.expanduser('~')) + '/.tnote'

# Makes sure that the length of a string is a multiple of 32. Otherwise it
# is padded with the '^' character
pad_string = lambda s: s + (32 - len(s) % 32) * '^'

if os.name != 'nt':
    password = getpass.getpass("Please enter your key: ")
    key = hashlib.sha256(password.encode('utf-8')).digest()
    cryptor = AES.new(key)
    passphrase = getpass.getpass("Please enter your passphrase: ")
    crypted_pass = cryptor.encrypt(pad_string(passphrase))
    db = SqlCipherDatabase(path + '/diary.db', passphrase=str(crypted_pass))
else:
    db = SqliteDatabase(path + '/diary.db')

finish_key = "ctrl+Z" if os.name == 'nt' else "ctrl+D"


class DiaryEntry(Model):
    """The main Diray Model"""
    title = CharField()
    content = TextField()
    timestamp = DateTimeField(default=datetime.datetime.now)
    tags = CharField()

    class Meta:
        database = db
Exemple #3
0
    num_chars = len(alphabet)
    chars = []
    while len(chars) < length:
        num, idx = divmod(num, num_chars)
        chars.append(alphabet[idx])

    return "".join(chars)


def generate(ktmp):
    tmp = ("".join(choice("ABCDEFGHIJKLMNOPQRST12345") for i in range(20)))
    return password(ktmp, tmp)


db = SqlCipherDatabase(None)


class Service(Model):
    name = CharField()
    savedpassword = CharField()

    class Meta:
        database = db


def add_entry():
    """Add entry"""
    serv = raw_input("\nService name\n\n")
    masterpass = raw_input("\nPassword\n\n")
    Service.create(name=serv, savedpassword=masterpass)
Exemple #4
0
import datetime
from environs import Env
from playhouse.sqlcipher_ext import SqlCipherDatabase, Model, CharField, \
    ForeignKeyField, DateTimeField

env = Env()
env.read_env()
db = SqlCipherDatabase('config.db', passphrase=env.SQLITE_ENCRYPTION_KEY)


class BaseModel(Model):
    class Meta:
        database = db


class Client(BaseModel):
    db_user = CharField()
    db_password = CharField()
    db_host = CharField()
    db_driver = CharField()
    db_host = CharField()


class Configuration(BaseModel):
    timestamp = DateTimeField(default=datetime.datetime.now)
    connection_info = ForeignKeyField(Client, backref='clients')
    application = CharField()
    environment = CharField()