本文整理汇总了C#中KeePassLib.Keys.CompositeKey类的典型用法代码示例。如果您正苦于以下问题:C# CompositeKey类的具体用法?C# CompositeKey怎么用?C# CompositeKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompositeKey类属于KeePassLib.Keys命名空间,在下文中一共展示了CompositeKey类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: KeyFromCommandLine
public static CompositeKey KeyFromCommandLine(CommandLineArgs args)
{
if(args == null) throw new ArgumentNullException("args");
CompositeKey cmpKey = new CompositeKey();
string strPassword = args[AppDefs.CommandLineOptions.Password];
string strKeyFile = args[AppDefs.CommandLineOptions.KeyFile];
string strUserAcc = args[AppDefs.CommandLineOptions.UserAccount];
if(strPassword != null)
cmpKey.AddUserKey(new KcpPassword(strPassword));
if(strKeyFile != null)
{
try { cmpKey.AddUserKey(new KcpKeyFile(strKeyFile)); }
catch(Exception exKey)
{
MessageService.ShowWarning(strKeyFile, KPRes.KeyFileError, exKey);
return null;
}
}
if(strUserAcc != null)
{
try { cmpKey.AddUserKey(new KcpUserAccount()); }
catch(Exception exUA)
{
MessageService.ShowWarning(exUA);
return null;
}
}
return ((cmpKey.UserKeyCount > 0) ? cmpKey : null);
}
开发者ID:jonbws,项目名称:strengthreport,代码行数:34,代码来源:KeyUtil.cs
示例2: Main
public static void Main(string[] args)
{
CompositeKey key = new CompositeKey();
KcpPassword pw = new KcpPassword("12345");
key.AddUserKey(pw);
byte[] pwdata = pw.KeyData.ReadData();
Console.WriteLine("PW data:");
Console.WriteLine(string.Join(",", pwdata.Select(x => "0x" + x.ToString("x"))));
byte[] keydata = key.GenerateKey32(pwdata, 6000).ReadData();
Console.WriteLine("Key data:");
Console.WriteLine(string.Join(",", keydata.Select(x => "0x" + x.ToString("x"))));
PwDatabase db = new PwDatabase();
db.MasterKey = key;
KdbxFile kdbx = new KdbxFile(db);
kdbx.Load(@"..\resources\test.kdbx", KdbxFormat.Default, null);
var groups = db.RootGroup.GetGroups(true);
Console.WriteLine("Group count: " + groups.UCount);
var entries = db.RootGroup.GetEntries(true);
Console.WriteLine("Entry count: " + entries.UCount);
CompositeKey key2 = new CompositeKey();
key2.AddUserKey(pw);
KcpKeyFile keyfile = new KcpKeyFile(@"..\resources\keyfile.key");
key2.AddUserKey(keyfile);
byte[] keyfiledata = keyfile.KeyData.ReadData();
Console.WriteLine("Key file data:");
Console.WriteLine(string.Join(",", keyfiledata.Select(x => "0x" + x.ToString("x"))));
Console.WriteLine("Composite Key data:");
byte[] key2data = key2.GenerateKey32(keyfiledata, 6000).ReadData();
Console.WriteLine(string.Join(",", key2data.Select(x => "0x" + x.ToString("x"))));
}
开发者ID:jdonofrio728,项目名称:keepassj,代码行数:33,代码来源:test.cs
示例3: CreateKey
protected static CompositeKey CreateKey(string password, string keyfile)
{
CompositeKey key = new CompositeKey();
key.AddUserKey(new KcpPassword(password));
if (!String.IsNullOrEmpty(keyfile))
key.AddUserKey(new KcpKeyFile(keyfile));
return key;
}
开发者ID:pythe,项目名称:wristpass,代码行数:8,代码来源:TestBase.cs
示例4: CreateDb
public CreateDb(IKp2aApp app, Context ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave, CompositeKey key)
: base(finish)
{
_ctx = ctx;
_ioc = ioc;
_dontSave = dontSave;
_app = app;
_key = key;
}
开发者ID:pythe,项目名称:wristpass,代码行数:9,代码来源:CreateDB.cs
示例5: LoadDb
public LoadDb(IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnFinish finish)
: base(finish)
{
_app = app;
_ioc = ioc;
_databaseData = databaseData;
_compositeKey = compositeKey;
_keyfileOrProvider = keyfileOrProvider;
_rememberKeyfile = app.GetBooleanPreference(PreferenceKey.remember_keyfile);
}
开发者ID:pythe,项目名称:wristpass,代码行数:11,代码来源:LoadDB.cs
示例6: CreateKeePassDatabase
public static PwDatabase CreateKeePassDatabase(string databasePath, CompositeKey compositeKey)
{
if (!databasePath.EndsWith(".kdbx"))
throw new FileNotFoundException("The database file must end with .kdbx");
var directoryName = Path.GetDirectoryName(databasePath);
var fileName = Path.GetFileName(databasePath);
if (!Directory.Exists(directoryName))
Directory.CreateDirectory(directoryName);
var ioc = new IOConnectionInfo();
ioc.Path = fileName;
ioc.CredSaveMode = IOCredSaveMode.NoSave;
var database = new PwDatabase();
database.New(ioc, compositeKey);
database.Save(null);
return database;
}
开发者ID:badmishkallc,项目名称:jolt9-devops,代码行数:21,代码来源:Util.cs
示例7: CreateCompositeKey
public static CompositeKey CreateCompositeKey(string keyPassword = null, string keyFile = null, bool userAccount = false)
{
var emptyPassword = string.IsNullOrWhiteSpace(keyPassword);
var emptyKeyFile = string.IsNullOrWhiteSpace(keyFile);
if(emptyPassword && emptyKeyFile && !userAccount)
throw new ArgumentException("KeyPass requires at least one form of authentication: Password, KeyFile, or UserAccount");
var key = new CompositeKey();
if (!emptyPassword)
key.AddUserKey(new KcpPassword(keyPassword));
if (!emptyKeyFile)
key.AddUserKey(new KcpKeyFile(keyFile));
if (userAccount)
key.AddUserKey(new KcpUserAccount());
return key;
}
开发者ID:badmishkallc,项目名称:jolt9-devops,代码行数:21,代码来源:Util.cs
示例8: Run
public override void Run()
{
StatusLogger.UpdateMessage(UiStringKey.progress_create);
Database db = _app.CreateNewDatabase();
db.KpDatabase = new KeePassLib.PwDatabase();
if (_key == null)
{
_key = new CompositeKey(); //use a temporary key which should be changed after creation
}
db.KpDatabase.New(_ioc, _key);
db.KpDatabase.KeyEncryptionRounds = DefaultEncryptionRounds;
db.KpDatabase.Name = "Keepass2Android Password Database";
//re-set the name of the root group because the PwDatabase uses UrlUtil which is not appropriate for all file storages:
db.KpDatabase.RootGroup.Name = _app.GetFileStorage(_ioc).GetFilenameWithoutPathAndExt(_ioc);
// Set Database state
db.Root = db.KpDatabase.RootGroup;
db.Loaded = true;
db.SearchHelper = new SearchDbHelper(_app);
// Add a couple default groups
AddGroup internet = AddGroup.GetInstance(_ctx, _app, "Internet", 1, db.KpDatabase.RootGroup, null, true);
internet.Run();
AddGroup email = AddGroup.GetInstance(_ctx, _app, "eMail", 19, db.KpDatabase.RootGroup, null, true);
email.Run();
// Commit changes
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, _dontSave);
save.SetStatusLogger(StatusLogger);
_onFinishToRun = null;
save.Run();
}
开发者ID:pythe,项目名称:wristpass,代码行数:36,代码来源:CreateDB.cs
示例9: OpenDatabaseInternal
private PwDatabase OpenDatabaseInternal(IOConnectionInfo ioc,
CompositeKey cmpKey, out bool bAbort)
{
bAbort = false;
PerformSelfTest();
ShowWarningsLogger swLogger = CreateShowWarningsLogger();
swLogger.StartLogging(KPRes.OpeningDatabase, true);
PwDocument ds = null;
string strPathNrm = ioc.Path.Trim().ToLower();
for(int iScan = 0; iScan < m_docMgr.Documents.Count; ++iScan)
{
if(m_docMgr.Documents[iScan].LockedIoc.Path.Trim().ToLower() == strPathNrm)
ds = m_docMgr.Documents[iScan];
else if(m_docMgr.Documents[iScan].Database.IOConnectionInfo.Path == strPathNrm)
ds = m_docMgr.Documents[iScan];
}
PwDatabase pwDb;
if(ds == null) pwDb = m_docMgr.CreateNewDocument(true).Database;
else pwDb = ds.Database;
Exception ex = null;
try
{
pwDb.Open(ioc, cmpKey, swLogger);
#if DEBUG
byte[] pbDiskDirect = WinUtil.HashFile(ioc);
Debug.Assert(MemUtil.ArraysEqual(pbDiskDirect, pwDb.HashOfFileOnDisk));
#endif
}
catch(Exception exLoad)
{
ex = exLoad;
pwDb = null;
}
swLogger.EndLogging();
if(pwDb == null)
{
if(ds == null) m_docMgr.CloseDatabase(m_docMgr.ActiveDatabase);
}
if(ex != null)
{
string strMsg = MessageService.GetLoadWarningMessage(
ioc.GetDisplayName(), ex,
(Program.CommandLineArgs[AppDefs.CommandLineOptions.Debug] != null));
bool bShowStd = true;
if(!ioc.IsLocalFile())
{
VistaTaskDialog vtd = new VistaTaskDialog();
vtd.CommandLinks = false;
vtd.Content = strMsg;
vtd.DefaultButtonID = (int)DialogResult.Cancel;
// vtd.VerificationText = KPRes.CredSpecifyDifferent;
vtd.WindowTitle = PwDefs.ShortProductName;
vtd.SetIcon(VtdIcon.Warning);
vtd.AddButton((int)DialogResult.Cancel, KPRes.Ok, null);
vtd.AddButton((int)DialogResult.Retry,
KPRes.CredSpecifyDifferent, null);
if(vtd.ShowDialog(this))
{
bShowStd = false;
// if(vtd.ResultVerificationChecked)
if(vtd.Result == (int)DialogResult.Retry)
{
IOConnectionInfo iocNew = ioc.CloneDeep();
// iocNew.ClearCredentials(false);
iocNew.CredSaveMode = IOCredSaveMode.NoSave;
iocNew.IsComplete = false;
// iocNew.Password = string.Empty;
OpenDatabase(iocNew, null, false);
bAbort = true;
}
}
}
if(bShowStd) MessageService.ShowWarning(strMsg);
// MessageService.ShowLoadWarning(ioc.GetDisplayName(), ex,
// (Program.CommandLineArgs[AppDefs.CommandLineOptions.Debug] != null));
}
return pwDb;
}
开发者ID:riking,项目名称:go-keepass2,代码行数:95,代码来源:MainForm_Functions.cs
示例10: OpenDatabase
/// <summary>
/// Open a database. This function opens the specified database and updates
/// the user interface.
/// </summary>
public void OpenDatabase(IOConnectionInfo ioConnection, CompositeKey cmpKey,
bool bOpenLocal)
{
if(!m_bFormLoaded && Program.Config.Application.Start.MinimizedAndLocked &&
(ioConnection != null) && (ioConnection.Path.Length > 0))
{
PwDocument ds = m_docMgr.CreateNewDocument(true);
ds.LockedIoc = ioConnection.CloneDeep();
UpdateUI(true, ds, true, null, true, null, false);
return;
}
SaveWindowState(); // KPF 1093
IOConnectionInfo ioc;
if(ioConnection == null)
{
if(bOpenLocal)
{
OpenFileDialogEx ofdDb = UIUtil.CreateOpenFileDialog(KPRes.OpenDatabaseFile,
UIUtil.CreateFileTypeFilter(AppDefs.FileExtension.FileExt,
KPRes.KdbxFiles, true), 1, null, false,
AppDefs.FileDialogContext.Database);
GlobalWindowManager.AddDialog(ofdDb.FileDialog);
DialogResult dr = ofdDb.ShowDialog();
GlobalWindowManager.RemoveDialog(ofdDb.FileDialog);
if(dr != DialogResult.OK) return;
ioc = IOConnectionInfo.FromPath(ofdDb.FileName);
}
else
{
ioc = CompleteConnectionInfo(new IOConnectionInfo(), false,
true, true, true);
if(ioc == null) return;
}
}
else // ioConnection != null
{
ioc = CompleteConnectionInfo(ioConnection, false, true, true, false);
if(ioc == null) return;
}
if(!ioc.CanProbablyAccess())
{
MessageService.ShowWarning(ioc.GetDisplayName(), KPRes.FileNotFoundError);
return;
}
if(OpenDatabaseRestoreIfOpened(ioc)) return;
PwDatabase pwOpenedDb = null;
bool bAbort;
if(cmpKey == null)
{
for(int iTry = 0; iTry < 3; ++iTry)
{
OdKpfConstructParams kpfParams = new OdKpfConstructParams();
kpfParams.IOConnectionInfo = ioc;
kpfParams.CanExit = IsFileLocked(null);
DialogResult dr;
OdKpfResult kpfResult;
if(Program.Config.Security.MasterKeyOnSecureDesktop &&
WinUtil.IsAtLeastWindows2000 &&
!KeePassLib.Native.NativeLib.IsUnix())
{
kpfParams.SecureDesktopMode = true;
ProtectedDialog dlg = new ProtectedDialog(OdKpfConstruct,
OdKpfBuildResult);
object objResult;
dr = dlg.ShowDialog(out objResult, kpfParams);
if(dr == DialogResult.None) { Debug.Assert(false); dr = DialogResult.Cancel; }
kpfResult = (objResult as OdKpfResult);
if(kpfResult == null) { Debug.Assert(false); continue; }
if(kpfResult.ShowHelpAfterClose)
AppHelp.ShowHelp(AppDefs.HelpTopics.KeySources, null);
}
else // Show dialog on normal desktop
{
Form dlg = OdKpfConstruct(kpfParams);
dr = dlg.ShowDialog();
kpfResult = (OdKpfBuildResult(dlg) as OdKpfResult);
UIUtil.DestroyForm(dlg);
if(kpfResult == null) { Debug.Assert(false); continue; }
}
if(dr == DialogResult.Cancel) break;
else if(kpfResult.HasClosedWithExit)
{
//.........这里部分代码省略.........
开发者ID:riking,项目名称:go-keepass2,代码行数:101,代码来源:MainForm_Functions.cs
示例11: CreateKeyFor
public static CompositeKey CreateKeyFor(string password)
{
CompositeKey key = new CompositeKey();
key.AddUserKey(new KcpPassword(password));
return key;
}
开发者ID:hicknhack-software,项目名称:KeeShare,代码行数:6,代码来源:SyncSource.cs
示例12: CreateDatabase
private void CreateDatabase()
{
var keyfileCheckbox = FindViewById<CheckBox>(Resource.Id.use_keyfile);
string password;
if (!TryGetPassword(out password)) return;
// Verify that a password or keyfile is set
if (password.Length == 0 && !keyfileCheckbox.Checked)
{
Toast.MakeText(this, Resource.String.error_nopass, ToastLength.Long).Show();
return;
}
//create the key
CompositeKey newKey = new CompositeKey();
if (String.IsNullOrEmpty(password) == false)
{
newKey.AddUserKey(new KcpPassword(password));
}
if (String.IsNullOrEmpty(_keyfileFilename) == false)
{
try
{
newKey.AddUserKey(new KcpKeyFile(_keyfileFilename));
}
catch (Exception)
{
Toast.MakeText(this, Resource.String.error_adding_keyfile, ToastLength.Long).Show();
return;
}
}
// Create the new database
CreateDb create = new CreateDb(App.Kp2a, this, _ioc, new LaunchGroupActivity(_ioc, this), false, newKey);
ProgressTask createTask = new ProgressTask(
App.Kp2a,
this, create);
createTask.Run();
}
开发者ID:pythe,项目名称:wristpass,代码行数:39,代码来源:CreateDatabaseActivity.cs
示例13: LoadDatabase
public void LoadDatabase(IOConnectionInfo ioConnectionInfo, MemoryStream memoryStream, CompositeKey compKey, ProgressDialogStatusLogger statusLogger, IDatabaseFormat databaseFormat)
{
_db.LoadData(this, ioConnectionInfo, memoryStream, compKey, statusLogger, databaseFormat);
}
开发者ID:pythe,项目名称:wristpass,代码行数:4,代码来源:TestKp2aApp.cs
示例14: OpenDatabaseInternal
private PwDatabase OpenDatabaseInternal(IOConnectionInfo ioc, CompositeKey cmpKey)
{
PerformSelfTest();
ShowWarningsLogger swLogger = CreateShowWarningsLogger();
swLogger.StartLogging(KPRes.OpeningDatabase, true);
PwDocument ds = null;
string strPathNrm = ioc.Path.Trim().ToLower();
for(int iScan = 0; iScan < m_docMgr.Documents.Count; ++iScan)
{
if(m_docMgr.Documents[iScan].LockedIoc.Path.Trim().ToLower() == strPathNrm)
ds = m_docMgr.Documents[iScan];
else if(m_docMgr.Documents[iScan].Database.IOConnectionInfo.Path == strPathNrm)
ds = m_docMgr.Documents[iScan];
}
PwDatabase pwDb;
if(ds == null) pwDb = m_docMgr.CreateNewDocument(true).Database;
else pwDb = ds.Database;
try
{
pwDb.Open(ioc, cmpKey, swLogger);
#if DEBUG
byte[] pbDiskDirect = WinUtil.HashFile(ioc);
Debug.Assert(MemUtil.ArraysEqual(pbDiskDirect, pwDb.HashOfFileOnDisk));
#endif
}
catch(Exception ex)
{
MessageService.ShowLoadWarning(ioc.GetDisplayName(), ex);
pwDb = null;
}
swLogger.EndLogging();
if(pwDb == null)
{
if(ds == null) m_docMgr.CloseDatabase(m_docMgr.ActiveDatabase);
}
return pwDb;
}
开发者ID:elitak,项目名称:keepass,代码行数:45,代码来源:MainForm_Functions.cs
示例15: CreateCompositeKey
private bool CreateCompositeKey()
{
m_pKey = new CompositeKey();
if(m_cbPassword.Checked) // Use a password
{
if(!m_icgPassword.ValidateData(true)) return false;
uint uPwLen = m_icgPassword.PasswordLength;
if(uPwLen == 0)
{
if(!MessageService.AskYesNo(KPRes.EmptyMasterPw +
MessageService.NewParagraph + KPRes.EmptyMasterPwHint +
MessageService.NewParagraph + KPRes.EmptyMasterPwQuestion,
null, false))
{
return false;
}
}
uint uMinLen = Program.Config.Security.MasterPassword.MinimumLength;
if(uPwLen < uMinLen)
{
string strML = KPRes.MasterPasswordMinLengthFailed;
strML = strML.Replace(@"{PARAM}", uMinLen.ToString());
MessageService.ShowWarning(strML);
return false;
}
byte[] pb = m_icgPassword.GetPasswordUtf8();
uint uMinQual = Program.Config.Security.MasterPassword.MinimumQuality;
if(QualityEstimation.EstimatePasswordBits(pb) < uMinQual)
{
string strMQ = KPRes.MasterPasswordMinQualityFailed;
strMQ = strMQ.Replace(@"{PARAM}", uMinQual.ToString());
MessageService.ShowWarning(strMQ);
Array.Clear(pb, 0, pb.Length);
return false;
}
string strValRes = Program.KeyValidatorPool.Validate(pb,
KeyValidationType.MasterPassword);
if(strValRes != null)
{
MessageService.ShowWarning(strValRes);
Array.Clear(pb, 0, pb.Length);
return false;
}
m_pKey.AddUserKey(new KcpPassword(pb));
Array.Clear(pb, 0, pb.Length);
}
string strKeyFile = m_cmbKeyFile.Text;
bool bIsKeyProv = Program.KeyProviderPool.IsKeyProvider(strKeyFile);
if(m_cbKeyFile.Checked && (!strKeyFile.Equals(KPRes.NoKeyFileSpecifiedMeta)) &&
!bIsKeyProv)
{
try { m_pKey.AddUserKey(new KcpKeyFile(strKeyFile, true)); }
catch(InvalidDataException exID) // Selected database file
{
MessageService.ShowWarning(strKeyFile, exID);
return false;
}
catch(Exception exKF)
{
MessageService.ShowWarning(strKeyFile, KPRes.KeyFileError, exKF);
return false;
}
}
else if(m_cbKeyFile.Checked && (!strKeyFile.Equals(KPRes.NoKeyFileSpecifiedMeta)) &&
bIsKeyProv)
{
KeyProviderQueryContext ctxKP = new KeyProviderQueryContext(
m_ioInfo, true, false);
bool bPerformHash;
byte[] pbCustomKey = Program.KeyProviderPool.GetKey(strKeyFile, ctxKP,
out bPerformHash);
if((pbCustomKey != null) && (pbCustomKey.Length > 0))
{
try { m_pKey.AddUserKey(new KcpCustomKey(strKeyFile, pbCustomKey, bPerformHash)); }
catch(Exception exCKP)
{
MessageService.ShowWarning(exCKP);
return false;
}
Array.Clear(pbCustomKey, 0, pbCustomKey.Length);
}
else return false; // Provider has shown error message
}
if(m_cbUserAccount.Checked)
{
try { m_pKey.AddUserKey(new KcpUserAccount()); }
catch(Exception exUA)
{
//.........这里部分代码省略.........
开发者ID:ashwingj,项目名称:keepass2,代码行数:101,代码来源:KeyCreationForm.cs
示例16: EqualsValue
public bool EqualsValue(CompositeKey ckOther)
{
if(ckOther == null) throw new ArgumentNullException("ckOther");
byte[] pbThis = CreateRawCompositeKey32();
byte[] pbOther = ckOther.CreateRawCompositeKey32();
bool bResult = MemUtil.ArraysEqual(pbThis, pbOther);
Array.Clear(pbOther, 0, pbOther.Length);
Array.Clear(pbThis, 0, pbThis.Length);
return bResult;
}
开发者ID:rassilon,项目名称:keepass,代码行数:12,代码来源:CompositeKey.cs
示例17: CreateCompositeKey
private bool CreateCompositeKey()
{
m_pKey = new CompositeKey();
if(m_cbPassword.Checked) // Use a password
{
byte[] pb = m_secPassword.ToUtf8();
m_pKey.AddUserKey(new KcpPassword(pb));
MemUtil.ZeroByteArray(pb);
}
string strKeyFile = m_cmbKeyFile.Text;
Debug.Assert(strKeyFile != null); if(strKeyFile == null) strKeyFile = string.Empty;
bool bIsProvKey = Program.KeyProviderPool.IsKeyProvider(strKeyFile);
if(m_cbKeyFile.Checked && !strKeyFile.Equals(KPRes.NoKeyFileSpecifiedMeta) &&
!bIsProvKey)
{
if(!ValidateKeyFile()) return false;
try { m_pKey.AddUserKey(new KcpKeyFile(strKeyFile)); }
catch(Exception)
{
MessageService.ShowWarning(strKeyFile, KPRes.KeyFileError);
return false;
}
}
else if(m_cbKeyFile.Checked && !strKeyFile.Equals(KPRes.NoKeyFileSpecifiedMeta) &&
bIsProvKey)
{
KeyProvider kp = Program.KeyProviderPool.Get(strKeyFile);
if((kp != null) && m_bSecureDesktop)
{
if(!kp.SecureDesktopCompatible)
{
MessageService.ShowWarning(KPRes.KeyProvIncmpWithSD,
KPRes.KeyProvIncmpWithSDHint);
return false;
}
}
KeyProviderQueryContext ctxKP = new KeyProviderQueryContext(
m_ioInfo, false, m_bSecureDesktop);
bool bPerformHash;
byte[] pbProvKey = Program.KeyProviderPool.GetKey(strKeyFile, ctxKP,
out bPerformHash);
if((pbProvKey != null) && (pbProvKey.Length > 0))
{
try { m_pKey.AddUserKey(new KcpCustomKey(strKeyFile, pbProvKey, bPerformHash)); }
catch(Exception exCKP)
{
MessageService.ShowWarning(exCKP);
return false;
}
MemUtil.ZeroByteArray(pbProvKey);
}
else return false; // Provider has shown error message
}
if(m_cbUserAccount.Checked)
{
try { m_pKey.AddUserKey(new KcpUserAccount()); }
catch(Exception exUA)
{
MessageService.ShowWarning(exUA);
return false;
}
}
return true;
}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:73,代码来源:KeyPromptForm.cs
示例18: CreateCompositeKey
private bool CreateCompositeKey()
{
m_pKey = new CompositeKey();
if(m_cbPassword.Checked) // Use a password
{
byte[] pb = m_secPassword.ToUtf8();
m_pKey.AddUserKey(new KcpPassword(pb));
Array.Clear(pb, 0, pb.Length);
}
string strKeyFile = m_cmbKeyFile.Text;
Debug.Assert(strKeyFile != null); if(strKeyFile == null) strKeyFile = string.Empty;
bool bIsProvKey = Program.KeyProviderPool.IsKeyProvider(strKeyFile);
if(m_cbKeyFile.Checked && (!strKeyFile.Equals(KPRes.NoKeyFileSpecifiedMeta)) &&
(bIsProvKey == false))
{
if(ValidateKeyFileLocation() == false)
{
m_pKey = null;
return false;
}
try { m_pKey.AddUserKey(new KcpKeyFile(strKeyFile)); }
catch(Exception)
{
MessageService.ShowWarning(strKeyFile, KPRes.KeyFileError);
m_pKey = null;
return false;
}
}
else if(m_cbKeyFile.Checked && (!strKeyFile.Equals(KPRes.NoKeyFileSpecifiedMeta)) &&
(bIsProvKey == true))
{
byte[] pbProvKey = Program.KeyProviderPool.GetKey(strKeyFile);
try { m_pKey.AddUserKey(new KcpCustomKey(pbProvKey)); }
catch(Exception exCKP)
{
MessageService.ShowWarning(strKeyFile, KPRes.KeyFileError, exCKP);
m_pKey = null;
return false;
}
if((pbProvKey != null) && (pbProvKey.Length > 0))
Array.Clear(pbProvKey, 0, pbProvKey.Length);
}
if(m_cbUserAccount.Checked)
{
try { m_pKey.AddUserKey(new KcpUserAccount()); }
catch(Exception exUA)
{
MessageService.ShowWarning(exUA);
return false;
}
}
return true;
}
开发者ID:jonbws,项目名称:strengthreport,代码行数:61,代码来源:KeyPromptForm.cs
示例19: OpenDatabaseInternal
private PwDatabase OpenDatabaseInternal(IOConnectionInfo ioc, CompositeKey cmpKey)
{
PerformSelfTest ();
//string strPathNrm = ioc.Path.Trim().ToLower();
PwDatabase pwDb = new PwDatabase ();
try {
pwDb.Open (ioc, cmpKey, null);
}
catch (Exception ex) {
//MessageService.ShowLoadWarning(ioc.GetDisplayName(), ex,
// (Program.CommandLineArgs[AppDefs.CommandLineOptions.Debug] != null));
pwDb = null;
throw;
}
return pwDb;
}
开发者ID:enecciari,项目名称:mackeepass,代码行数:20,代码来源:DatabaseCommands.cs
示例20: CreateCompositeKey
private CompositeKey CreateCompositeKey(string masterKey)
{
CompositeKey m_pKey = new CompositeKey ();
SecureEdit se = new SecureEdit (masterKey);
byte[] pb = se.ToUtf8 ();
m_pKey.AddUserKey (new KcpPassword (pb));
Array.Clear (pb, 0, pb.Length);
return m_pKey;
}
开发者ID:enecciari,项目名称:mackeepass,代码行数:11,代码来源:DatabaseCommands.cs
注:本文中的KeePassLib.Keys.CompositeKey类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论