diff --git a/Common/Exceptions/DatabaseExecuteException.cs b/Common/Exceptions/DatabaseExecuteException.cs index 5c2c0980..2490cb20 100644 --- a/Common/Exceptions/DatabaseExecuteException.cs +++ b/Common/Exceptions/DatabaseExecuteException.cs @@ -20,6 +20,6 @@ namespace Swarmops.Common.Exceptions } public string AttemptedCommand { get; } - public Exception InnerException { get; } + public new Exception InnerException { get; } } } diff --git a/Logic/Financial/ExternalBankData.cs b/Logic/Financial/ExternalBankData.cs index 40ba6904..d5e1ddee 100644 --- a/Logic/Financial/ExternalBankData.cs +++ b/Logic/Financial/ExternalBankData.cs @@ -131,6 +131,7 @@ namespace Swarmops.Logic.Financial } ExternalBankDataRecord newRecord = new ExternalBankDataRecord(); + newRecord.RawData = lineData; if (fieldNameLookup.ContainsKey(ExternalBankDataFieldName.DescriptionPrimary)) { diff --git a/Logic/Financial/ExternalBankDataRecord.cs b/Logic/Financial/ExternalBankDataRecord.cs index 38682ad1..749becf2 100644 --- a/Logic/Financial/ExternalBankDataRecord.cs +++ b/Logic/Financial/ExternalBankDataRecord.cs @@ -21,6 +21,8 @@ namespace Swarmops.Logic.Financial public long TransactionNetCents; public string UniqueId; + public string RawData; // Used for further discrimination among ambiguous records - may contain more uniqueness + #region Implementation of IComparer public int Compare (ExternalBankDataRecord x, ExternalBankDataRecord y) diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 0dcf8f7b..8be86998 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -232,6 +232,7 @@ + diff --git a/Logic/Security/SHA1.cs b/Logic/Security/SHA1.cs index e6caaa8d..efdf93c3 100644 --- a/Logic/Security/SHA1.cs +++ b/Logic/Security/SHA1.cs @@ -1,3 +1,4 @@ +using System; using System.Security.Cryptography; using System.Text; @@ -8,6 +9,7 @@ namespace Swarmops.Logic.Security /// public class SHA1 { + [Obsolete("Warning: SHA1 is considered insecure. Do not use for anything authentication or security related. Consider migrating to Sha256.")] public static string Hash (string input) { byte[] data = Encoding.GetEncoding (1252).GetBytes (input); diff --git a/Logic/Security/Sha256.cs b/Logic/Security/Sha256.cs new file mode 100644 index 00000000..c2fd18a7 --- /dev/null +++ b/Logic/Security/Sha256.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace Swarmops.Logic.Security +{ + public class Sha256 + { + public static string Compute(string input) + { + byte[] data = Encoding.GetEncoding(1252).GetBytes(input); + + System.Security.Cryptography.SHA256 Sha256 = new SHA256CryptoServiceProvider(); + byte[] hash = Sha256.ComputeHash(data); + + // Write the resulting hash to a string of hex values. + + StringBuilder result = new StringBuilder(); + + foreach (byte oneByte in hash) + { + result.Append(oneByte.ToString("X02") + " "); + } + + return result.ToString().TrimEnd(); + } + } +} diff --git a/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs b/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs index f38212c2..fd6821e1 100644 --- a/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs +++ b/Site/Pages/v5/Ledgers/UploadBankFiles.aspx.cs @@ -707,7 +707,7 @@ namespace Swarmops.Site.Pages.Ledgers FinancialTransaction transaction = FinancialTransaction.ImportWithStub(args.Organization.Identity, row.DateTime, assetAccount.Identity, amountCents, - row.Description, importKey, "" /* new SHA256 field */, + row.Description, importKey, Sha256.Compute (row.RawData), args.CurrentUser.Identity); if (transaction != null)