当前位置: 首页>>代码示例>>C#>>正文


C# Security.ProtectedBinary类代码示例

本文整理汇总了C#中KeePassLib.Security.ProtectedBinary的典型用法代码示例。如果您正苦于以下问题:C# ProtectedBinary类的具体用法?C# ProtectedBinary怎么用?C# ProtectedBinary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ProtectedBinary类属于KeePassLib.Security命名空间,在下文中一共展示了ProtectedBinary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: KcpCustomKey

        public KcpCustomKey(byte[] pbKeyData)
        {
            Debug.Assert(pbKeyData != null); if(pbKeyData == null) throw new ArgumentNullException("pbKeyData");

            SHA256Managed sha256 = new SHA256Managed();
            byte[] pbRaw = sha256.ComputeHash(pbKeyData);
            m_pbKey = new ProtectedBinary(true, pbRaw);
        }
开发者ID:jonbws,项目名称:strengthreport,代码行数:8,代码来源:KcpCustomKey.cs

示例2: KcpKeyFile

		public KcpKeyFile(string strKeyFile)
		{
			byte[] pbKey = LoadXmlKeyFile(strKeyFile);
			if(pbKey == null) pbKey = LoadKeyFile(strKeyFile);

			if(pbKey == null) throw new InvalidOperationException();

			m_strPath = strKeyFile;
			m_pbKeyData = new ProtectedBinary(true, pbKey);
		}
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:10,代码来源:KcpKeyFile.cs

示例3: SetKey

		private void SetKey(byte[] pbPasswordUtf8)
		{
			Debug.Assert(pbPasswordUtf8 != null);
			if(pbPasswordUtf8 == null) throw new ArgumentNullException("pbPasswordUtf8");

			SHA256Managed sha256 = new SHA256Managed();
			byte[] pbRaw = sha256.ComputeHash(pbPasswordUtf8);

			m_psPassword = new ProtectedString(true, pbPasswordUtf8);
			m_pbKeyData = new ProtectedBinary(true, pbRaw);
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:11,代码来源:KcpPassword.cs

示例4: GetKeyParts

		internal static ProtectedString GetKeyParts(byte[] pbPasswordUtf8, out ProtectedBinary pbKeyData)
		{
			Debug.Assert(pbPasswordUtf8 != null);
			if(pbPasswordUtf8 == null) throw new ArgumentNullException("pbPasswordUtf8");

			SHA256Managed sha256 = new SHA256Managed();
			byte[] pbRaw = sha256.ComputeHash(pbPasswordUtf8);

			var psPassword = new ProtectedString(true, pbPasswordUtf8);
			pbKeyData = new ProtectedBinary(true, pbRaw);
			return psPassword;
		}
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:12,代码来源:KcpPassword.cs

示例5: SetKey

		private void SetKey(byte[] pbPasswordUtf8)
		{
			Debug.Assert(pbPasswordUtf8 != null);
			if(pbPasswordUtf8 == null) throw new ArgumentNullException("pbPasswordUtf8");

#if (DEBUG && !KeePassLibSD)
			Debug.Assert(ValidatePassword(pbPasswordUtf8));
#endif

			byte[] pbRaw = CryptoUtil.HashSha256(pbPasswordUtf8);

			m_psPassword = new ProtectedString(true, pbPasswordUtf8);
			m_pbKeyData = new ProtectedBinary(true, pbRaw);
		}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:14,代码来源:KcpPassword.cs

示例6: KcpCustomKey

        public KcpCustomKey(string strName, byte[] pbKeyData, bool bPerformHash)
        {
            Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName");
            Debug.Assert(pbKeyData != null); if(pbKeyData == null) throw new ArgumentNullException("pbKeyData");

            m_strName = strName;

            if(bPerformHash)
            {
                SHA256Managed sha256 = new SHA256Managed();
                byte[] pbRaw = sha256.ComputeHash(pbKeyData);
                m_pbKey = new ProtectedBinary(true, pbRaw);
            }
            else m_pbKey = new ProtectedBinary(true, pbKeyData);
        }
开发者ID:elitak,项目名称:keepass,代码行数:15,代码来源:KcpCustomKey.cs

示例7: KcpUserAccount

		/// <summary>
		/// Construct a user account key.
		/// </summary>
		public KcpUserAccount()
		{
			// Test if ProtectedData is supported -- throws an exception
			// when running on an old system (Windows 98 / ME).
			byte[] pbDummyData = new byte[128];
			ProtectedData.Protect(pbDummyData, m_pbEntropy,
				DataProtectionScope.CurrentUser);

			byte[] pbKey = LoadUserKey(false);
			if(pbKey == null) pbKey = CreateUserKey();
			if(pbKey == null) throw new SecurityException(KLRes.UserAccountKeyError);

			m_pbKeyData = new ProtectedBinary(true, pbKey);
			Array.Clear(pbKey, 0, pbKey.Length);
		}
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:18,代码来源:KcpUserAccount.cs

示例8: KcpUserAccount

        /// <summary>
        /// Construct a user account key.
        /// </summary>
        public KcpUserAccount()
        {
            // Test if ProtectedData is supported -- throws an exception
            // when running on an old system (Windows 98 / ME).
            byte[] pbDummyData = new byte[128];
            ProtectedData.Protect(pbDummyData, m_pbEntropy,
                DataProtectionScope.CurrentUser);

            byte[] pbKey = LoadUserKey(false);
            if(pbKey == null) pbKey = CreateUserKey();
            if(pbKey == null) // Should never happen
            {
                Debug.Assert(false);
                throw new SecurityException(KLRes.UserAccountKeyError);
            }

            m_pbKeyData = new ProtectedBinary(true, pbKey);
            MemUtil.ZeroByteArray(pbKey);
        }
开发者ID:cappert,项目名称:keepass2,代码行数:22,代码来源:KcpUserAccount.cs

示例9: Init

		private void Init(bool bEnableProtection, byte[] pbUtf8)
		{
			if(pbUtf8 == null) throw new ArgumentNullException("pbUtf8");

			m_bIsProtected = bEnableProtection;

			if(bEnableProtection)
				m_pbUtf8 = new ProtectedBinary(true, pbUtf8);
			else
				m_strPlainText = StrUtil.Utf8.GetString(pbUtf8, 0, pbUtf8.Length);
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:11,代码来源:ProtectedString.cs

示例10: UpdateKeePassEntry

        public static void UpdateKeePassEntry(PwEntry entry,
            string username = "",
            string title = "",
            string url = "",
            string notes = "",
            string password = "",
            string[] attachments = null,
            string[] tags = null)
        {
            UpdateValue(entry, "UserName", username);
            UpdateValue(entry, "Title", title);
            UpdateValue(entry, "URL", url);
            UpdateValue(entry, "Notes", notes);
            UpdateValue(entry, "Password", password);

            if(tags != null)
            {
                var tagsCopy = entry.Tags.ToArray();
                foreach(var tag in tagsCopy)
                    entry.RemoveTag(tag);

                foreach (var tag in tags)
                    entry.AddTag(tag);
            }

            if (attachments != null)
            {
                var fileNames = attachments.Select(o => Path.GetFileName(o)).ToList();
                var binaries = entry.Binaries.CloneDeep();
                var filesToAdd = new List<string>();

                foreach(var binary in binaries)
                {
                    entry.Binaries.Remove(binary.Key);
                }

                foreach(var attachment in attachments)
                {
                    var fileName = Path.GetFileName(attachment);

                    var bytes = File.ReadAllBytes(attachment);
                    if(bytes != null)
                    {
                        var protectedBytes = new ProtectedBinary(true, bytes);
                        entry.Binaries.Set(fileName, protectedBytes);
                    }
                }
            }
        }
开发者ID:badmishkallc,项目名称:jolt9-devops,代码行数:49,代码来源:Util.cs

示例11: Construct

        private void Construct(IOConnectionInfo iocFile)
        {
            byte[] pbKey = LoadXmlKeyFile(iocFile);
            if(pbKey == null) pbKey = LoadKeyFile(iocFile);

            if(pbKey == null) throw new InvalidOperationException();

            m_strPath = iocFile.Path;
            m_pbKeyData = new ProtectedBinary(true, pbKey);
        }
开发者ID:amiryal,项目名称:keepass2,代码行数:10,代码来源:KcpKeyFile.cs

示例12: OnCtxBinNew

        private void OnCtxBinNew(object sender, EventArgs e)
        {
            if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return;

            string strName;
            for(int i = 0; ; ++i)
            {
                strName = KPRes.New;
                if(i >= 1) strName += " (" + i.ToString() + ")";
                strName += ".rtf";

                if(m_vBinaries.Get(strName) == null) break;
            }

            ProtectedBinary pb = new ProtectedBinary();
            m_vBinaries.Set(strName, pb);
            UpdateEntryBinaries(false, true, strName);
            ResizeColumnHeaders();

            ListViewItem lviNew = m_lvBinaries.FindItemWithText(strName,
                false, 0, false);
            if(lviNew != null) lviNew.BeginEdit();
        }
开发者ID:rdealexb,项目名称:keepass,代码行数:23,代码来源:PwEntryForm.cs

示例13: BinPoolFind

        private string BinPoolFind(ProtectedBinary pb)
        {
            if(pb == null) { Debug.Assert(false); return null; }

            foreach(KeyValuePair<string, ProtectedBinary> kvp in m_dictBinPool)
            {
                if(pb.Equals(kvp.Value)) return kvp.Key;
            }

            return null;
        }
开发者ID:saadware,项目名称:kpn,代码行数:11,代码来源:KdbxFile.cs

示例14: ProtectedBinary

		/// <summary>
		/// Construct a new protected binary data object. Copy the data from
		/// an existing object.
		/// </summary>
		/// <param name="pbTemplate">Existing <c>ProtectedBinary</c> object,
		/// which is used to initialize the new object. This parameter must
		/// not be <c>null</c>.</param>
		/// <exception cref="System.ArgumentNullException">Thrown if the input
		/// parameter is <c>null</c>.</exception>
		public ProtectedBinary(ProtectedBinary pbTemplate)
		{
			Debug.Assert(pbTemplate != null); if(pbTemplate == null) throw new ArgumentNullException("pbTemplate");

			m_bDoProtect = pbTemplate.m_bDoProtect;

			byte[] pbBuf = pbTemplate.ReadData();
			SetData(pbBuf);
			MemUtil.ZeroByteArray(pbBuf);
		}
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:19,代码来源:ProtectedBinary.cs

示例15: BinPoolAdd

        private void BinPoolAdd(ProtectedBinary pb)
        {
            if(pb == null) { Debug.Assert(false); return; }

            if(BinPoolFind(pb) != null) return; // Exists already

            m_dictBinPool.Add(m_dictBinPool.Count.ToString(), pb);
        }
开发者ID:saadware,项目名称:kpn,代码行数:8,代码来源:KdbxFile.cs


注:本文中的KeePassLib.Security.ProtectedBinary类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。