Exemple #1
0
        private Record GetRecordFromUri(string recordFileUri)
        {
            var encryptedBytes = DataGateway.GetBytes(recordFileUri);
            var record         = Cryptor.GetDecryptedContent <Record>(encryptedBytes, _password);

            return(record);
        }
Exemple #2
0
        public bool TryCreateSafeForExistingUser(string userName, string password, out ISafe safe)
        {
            var account = AccountGateway.ReadUserAccount(WorkingDirectory, userName);
            var verifyingWordBytesForCurrentPassword = Cryptor.GetEncryptedBytes(account.VerifyingWord, password);

            try
            {
                var masterPassword = Cryptor.GetDecryptedContent <string>(account.MasterEncryptedPassBytes, password);
                safe = null;

                if (account.VeryifyingWordEncryptedBytes.Length != verifyingWordBytesForCurrentPassword.Length)
                {
                    return(false);
                }
                for (var i = 0; i < account.VeryifyingWordEncryptedBytes.Length; i++)
                {
                    if (account.VeryifyingWordEncryptedBytes[i] != verifyingWordBytesForCurrentPassword[i])
                    {
                        return(false);
                    }
                }
                safe                  = new Safe(masterPassword);
                safe.UserName         = userName;
                safe.WorkingDirectory = WorkingDirectory;
                return(true);
            }
            catch (Exception e)
            {
                safe = null;
                return(false);
            }
        }
Exemple #3
0
        public void RetreiveFile(string recordId, string fileId, string fileUri)
        {
            var encryptedFileUri = GetEncryptedFileUri(recordId, fileId);
            var encryptedBytes   = DataGateway.GetBytes(encryptedFileUri);
            var fileByes         = Cryptor.GetDecryptedContent <byte[]>(encryptedBytes, _password);

            DataGateway.PutBytes(fileUri, fileByes);
        }