コード例 #1
0
ファイル: KeyedHasher .cs プロジェクト: cnarasimhagit/vm
        /// <summary>
        /// Initializes the asymmetric key.
        /// </summary>
        protected void InitializeHashKey()
        {
            if (!IsHashKeyInitialized)
            {
                if (KeyStorage.KeyLocationExists(KeyLocation))
                {
                    DecryptHashKey(
                        KeyStorage.GetKey(KeyLocation));
                }
                else
                {
                    KeyStorage.PutKey(EncryptHashKey(), KeyLocation);
                }

                IsHashKeyInitialized = true;
            }

            _hashAlgorithm.Initialize();
        }
コード例 #2
0
        /// <summary>
        /// Initializes the symmetric key for encryption.
        /// </summary>
        protected virtual void InitializeSymmetricKey()
        {
            if (IsSymmetricKeyInitialized)
            {
                return;
            }

            // get or create and put the file from/to its physical location
            if (KeyStorage.KeyLocationExists(KeyLocation))
            {
                DecryptSymmetricKey(KeyStorage.GetKey(KeyLocation));
            }
            else
            {
                Symmetric.GenerateKey();
                KeyStorage.PutKey(EncryptSymmetricKey(), KeyLocation);
            }

            IsSymmetricKeyInitialized = true;
        }