Skip to content

Commit

Permalink
Merge pull request #5 from shugaoye/master
Browse files Browse the repository at this point in the history
Support device lock.
  • Loading branch information
passxyz authored Apr 17, 2021
2 parents 79c8d20 + cf41cb1 commit fa94dbd
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 3 deletions.
231 changes: 231 additions & 0 deletions keepass.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,237 @@
"## Configuration file support"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Debug build 1.1.5.dev0\n"
]
}
],
"source": [
"import os\n",
"import kpclibpy.kpclib\n",
"import PassXYZLib"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Close',\n",
" 'Color',\n",
" 'Compression',\n",
" 'CurrentGroup',\n",
" 'CurrentPath',\n",
" 'CustomData',\n",
" 'CustomIcons',\n",
" 'DataCipherUuid',\n",
" 'DefaultFolder',\n",
" 'DefaultUserName',\n",
" 'DefaultUserNameChanged',\n",
" 'DeleteCustomIcons',\n",
" 'DeleteDuplicateEntries',\n",
" 'DeleteEmptyGroups',\n",
" 'DeleteEntry',\n",
" 'DeleteGroup',\n",
" 'DeleteUnusedCustomIcons',\n",
" 'DeletedObjects',\n",
" 'Description',\n",
" 'DescriptionChanged',\n",
" 'DetachBinaries',\n",
" 'EntryTemplatesGroup',\n",
" 'EntryTemplatesGroupChanged',\n",
" 'Equals',\n",
" 'Finalize',\n",
" 'FindByPath',\n",
" 'GetCustomIcon',\n",
" 'GetCustomIconIndex',\n",
" 'GetHashCode',\n",
" 'GetType',\n",
" 'HashOfFileOnDisk',\n",
" 'HashOfLastIO',\n",
" 'HistoryMaxItems',\n",
" 'HistoryMaxSize',\n",
" 'IOConnectionInfo',\n",
" 'IsOpen',\n",
" 'IsParentGroup',\n",
" 'KdfParameters',\n",
" 'LastSelectedGroup',\n",
" 'LastTopVisibleGroup',\n",
" 'LocalizedAppName',\n",
" 'MaintainBackups',\n",
" 'MaintenanceHistoryDays',\n",
" 'MasterKey',\n",
" 'MasterKeyChangeForce',\n",
" 'MasterKeyChangeForceOnce',\n",
" 'MasterKeyChangeRec',\n",
" 'MasterKeyChanged',\n",
" 'MemberwiseClone',\n",
" 'MemoryProtection',\n",
" 'MergeIn',\n",
" 'Modified',\n",
" 'MoveEntry',\n",
" 'MoveGroup',\n",
" 'Name',\n",
" 'NameChanged',\n",
" 'New',\n",
" 'Open',\n",
" 'Overloads',\n",
" 'PublicCustomData',\n",
" 'RecycleBinChanged',\n",
" 'RecycleBinEnabled',\n",
" 'RecycleBinUuid',\n",
" 'ReferenceEquals',\n",
" 'RootGroup',\n",
" 'Save',\n",
" 'SaveAs',\n",
" 'SettingsChanged',\n",
" 'ToString',\n",
" 'UINeedsIconUpdate',\n",
" 'UseFileLocks',\n",
" 'UseFileTransactions',\n",
" '__call__',\n",
" '__class__',\n",
" '__delattr__',\n",
" '__delitem__',\n",
" '__dir__',\n",
" '__doc__',\n",
" '__eq__',\n",
" '__format__',\n",
" '__ge__',\n",
" '__getattribute__',\n",
" '__getitem__',\n",
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__iter__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
" '__ne__',\n",
" '__new__',\n",
" '__overloads__',\n",
" '__reduce__',\n",
" '__reduce_ex__',\n",
" '__repr__',\n",
" '__setattr__',\n",
" '__setitem__',\n",
" '__sizeof__',\n",
" '__str__',\n",
" '__subclasshook__',\n",
" 'get_Color',\n",
" 'get_Compression',\n",
" 'get_CurrentGroup',\n",
" 'get_CurrentPath',\n",
" 'get_CustomData',\n",
" 'get_CustomIcons',\n",
" 'get_DataCipherUuid',\n",
" 'get_DefaultFolder',\n",
" 'get_DefaultUserName',\n",
" 'get_DefaultUserNameChanged',\n",
" 'get_DeletedObjects',\n",
" 'get_Description',\n",
" 'get_DescriptionChanged',\n",
" 'get_DetachBinaries',\n",
" 'get_EntryTemplatesGroup',\n",
" 'get_EntryTemplatesGroupChanged',\n",
" 'get_HashOfFileOnDisk',\n",
" 'get_HashOfLastIO',\n",
" 'get_HistoryMaxItems',\n",
" 'get_HistoryMaxSize',\n",
" 'get_IOConnectionInfo',\n",
" 'get_IsOpen',\n",
" 'get_KdfParameters',\n",
" 'get_LastSelectedGroup',\n",
" 'get_LastTopVisibleGroup',\n",
" 'get_LocalizedAppName',\n",
" 'get_MaintenanceHistoryDays',\n",
" 'get_MasterKey',\n",
" 'get_MasterKeyChangeForce',\n",
" 'get_MasterKeyChangeForceOnce',\n",
" 'get_MasterKeyChangeRec',\n",
" 'get_MasterKeyChanged',\n",
" 'get_MemoryProtection',\n",
" 'get_Modified',\n",
" 'get_Name',\n",
" 'get_NameChanged',\n",
" 'get_PublicCustomData',\n",
" 'get_RecycleBinChanged',\n",
" 'get_RecycleBinEnabled',\n",
" 'get_RecycleBinUuid',\n",
" 'get_RootGroup',\n",
" 'get_SettingsChanged',\n",
" 'get_UINeedsIconUpdate',\n",
" 'get_UseFileLocks',\n",
" 'get_UseFileTransactions',\n",
" 'set_Color',\n",
" 'set_Compression',\n",
" 'set_CurrentGroup',\n",
" 'set_DataCipherUuid',\n",
" 'set_DefaultFolder',\n",
" 'set_DefaultUserName',\n",
" 'set_DefaultUserNameChanged',\n",
" 'set_Description',\n",
" 'set_DescriptionChanged',\n",
" 'set_DetachBinaries',\n",
" 'set_EntryTemplatesGroup',\n",
" 'set_EntryTemplatesGroupChanged',\n",
" 'set_HistoryMaxItems',\n",
" 'set_HistoryMaxSize',\n",
" 'set_KdfParameters',\n",
" 'set_LastSelectedGroup',\n",
" 'set_LastTopVisibleGroup',\n",
" 'set_LocalizedAppName',\n",
" 'set_MaintenanceHistoryDays',\n",
" 'set_MasterKey',\n",
" 'set_MasterKeyChangeForce',\n",
" 'set_MasterKeyChangeForceOnce',\n",
" 'set_MasterKeyChangeRec',\n",
" 'set_MasterKeyChanged',\n",
" 'set_MemoryProtection',\n",
" 'set_Modified',\n",
" 'set_Name',\n",
" 'set_NameChanged',\n",
" 'set_RecycleBinChanged',\n",
" 'set_RecycleBinEnabled',\n",
" 'set_RecycleBinUuid',\n",
" 'set_RootGroup',\n",
" 'set_SettingsChanged',\n",
" 'set_UINeedsIconUpdate',\n",
" 'set_UseFileLocks',\n",
" 'set_UseFileTransactions']"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dir(PassXYZLib.PxDatabase)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Db = PassXYZLib.PxDatabase()\n",
"Db.set_DefaultFolder(\".\")"
]
},
{
"cell_type": "code",
"execution_count": 19,
Expand Down
7 changes: 4 additions & 3 deletions kpclibpy/commands/database_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ def open(dbfile: str, password = ""):
cprint("Database name: {}\nDescription: {}\nMaintenanceHistoryDays:{}"
.format(db.Name, db.Description, db.MaintenanceHistoryDays))
else:
logger = KPCLibPyLogger()
db_path = get_homepath() + '/' + dbfile
ctx.keepass.open(db_path, password, logger)
#logger = KPCLibPyLogger()
#db_path = get_homepath() + '/' + dbfile
#ctx.keepass.open(db_path, password, logger)
ctx.keepass.connect(dbfile, password)

ctx.keepass.file_name = dbfile

Expand Down
15 changes: 15 additions & 0 deletions kpclibpy/commands/keepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,21 @@ def close(self):
else:
print("Database connection is not established yet.")

def connect(self, filename, password):
"""
This command is used to connect a database.
connect supports device lock.
"""
self._db = PxDatabase()
try:
self._db.DefaultFolder = get_homepath()
self._db.Open(filename, password)
except InvalidCompositeKeyException:
self.close()
self._db = None
cprint("open: The composite key is invalid!", "red")
return

def open(self, db_path, password, logger):
ioc = IOConnectionInfo.FromPath(db_path)
cmpKey = CompositeKey()
Expand Down
Binary file modified kpclibpy/kpclib/lib/KPCLib.dll
Binary file not shown.
Binary file added kpclibpy/kpclib/lib/PassXYZ.dll
Binary file not shown.
Binary file modified kpclibpy/kpclib/lib/PassXYZLib.dll
Binary file not shown.

0 comments on commit fa94dbd

Please sign in to comment.