Adding an exception, SHA256
This commit is contained in:
@@ -20,6 +20,6 @@ namespace Swarmops.Common.Exceptions
|
||||
}
|
||||
|
||||
public string AttemptedCommand { get; }
|
||||
public Exception InnerException { get; }
|
||||
public new Exception InnerException { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ namespace Swarmops.Logic.Financial
|
||||
}
|
||||
|
||||
ExternalBankDataRecord newRecord = new ExternalBankDataRecord();
|
||||
newRecord.RawData = lineData;
|
||||
|
||||
if (fieldNameLookup.ContainsKey(ExternalBankDataFieldName.DescriptionPrimary))
|
||||
{
|
||||
|
||||
@@ -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<ExternalBankDataRecord>
|
||||
|
||||
public int Compare (ExternalBankDataRecord x, ExternalBankDataRecord y)
|
||||
|
||||
@@ -232,6 +232,7 @@
|
||||
<Compile Include="Communications\Payload\PayloadEnvelope.cs" />
|
||||
<Compile Include="Communications\Payload\NotificationPayload.cs" />
|
||||
<Compile Include="Security\Impersonation.cs" />
|
||||
<Compile Include="Security\Sha256.cs" />
|
||||
<Compile Include="Support\LogEntries\ApplicantAddedLogEntry.cs" />
|
||||
<Compile Include="Support\SharpCashAddr.cs" />
|
||||
<Compile Include="Support\SocketMessages\SocketMessageBase.cs" />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
@@ -8,6 +9,7 @@ namespace Swarmops.Logic.Security
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user