Skip to content

Commit

Permalink
Remove critical app settings from app.config
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-soule committed Jul 5, 2018
1 parent 19c07ad commit 530cd6b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
5 changes: 0 additions & 5 deletions App.config
Expand Up @@ -3,9 +3,4 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<appSettings>
<add key="testnet" value="true"/>
<add key="address" value="TXFjPSgevKLk1n7Z9TB2uRxDZTDaBjveC1"/>
<add key="reqConfirmations" value="0"/>
</appSettings>
</configuration>
2 changes: 1 addition & 1 deletion DNotesInvoicePOC.csproj
Expand Up @@ -24,7 +24,7 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
25 changes: 14 additions & 11 deletions MainWindow.xaml.cs
Expand Up @@ -28,8 +28,11 @@ namespace DNotesInvoicePOC
public partial class MainWindow : Window
{
private const long DNotesToSatoshi = 100000000;
private const string salt = "hcH3Cm3gPn3O2zQLqzjrnQ==";
private const string key = "SdrkxNdzwj7TMqwY";
private const string Salt = "hcH3Cm3gPn3O2zQLqzjrnQ==";
private const string Key = "SdrkxNdzwj7TMqwY";
private const bool Testnet = true;
private const string Address = "TXFjPSgevKLk1n7Z9TB2uRxDZTDaBjveC1";
private const int ReqConfirmations = 6;

private string StateFile = Directory.GetCurrentDirectory() + "\\subscription.json";

Expand Down Expand Up @@ -100,10 +103,10 @@ private void GenerateQRCodeAndLink(dynamic state)

var qrcode = new QRCodeWriter();
var price = (double)state.price / DNotesToSatoshi;
var qrValue = string.Format("dnotes:{0}?amount={1}&invoice={2}", ConfigurationManager.AppSettings["address"], price, state.invoice);
var qrValue = string.Format("dnotes:{0}?amount={1}&invoice={2}", Address, price, state.invoice);

var payText = string.Format("Please <a href='{0}'>pay</a> {1} NOTE to {2} for invoice {3}.\nWhen payment is verified, software will become active.",
qrValue, price, ConfigurationManager.AppSettings["address"], state.invoice);
qrValue, price, Address, state.invoice);

var xaml = HtmlToXamlConverter.ConvertHtmlToXaml(payText, true);
var flowDocument = XamlReader.Parse(xaml);
Expand Down Expand Up @@ -171,7 +174,7 @@ private void CreateSubscription(SubscriptionType t)

var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
var expiration = DateTimeOffset.MaxValue.ToUnixTimeSeconds();
var reqConfirmations = int.Parse(ConfigurationManager.AppSettings["reqConfirmations"]);
var reqConfirmations = ReqConfirmations;

double priceUSD = 0;
switch (t)
Expand Down Expand Up @@ -215,7 +218,7 @@ private bool CheckSubscription()
var invoice = json.invoice;
var price = long.Parse((string) json.price);

if (!CheckPayment((string) invoice, price, ConfigurationManager.AppSettings["address"], int.Parse(ConfigurationManager.AppSettings["reqConfirmations"])))
if (!CheckPayment((string) invoice, price, Address, ReqConfirmations))
{
return false;
}
Expand Down Expand Up @@ -249,7 +252,7 @@ private bool CheckPayment(string invoice, long price, string address, int reqCon

string url = "";

if (bool.Parse(ConfigurationManager.AppSettings["testnet"]))
if (Testnet)
{
url = @"http://dnotesdevlinux4.southcentralus.cloudapp.azure.com/chain/DNotesTestnet/q/invoice/" + address + '+' + invoice;
}
Expand Down Expand Up @@ -375,8 +378,8 @@ private void EncryptFile(string path)
{
var content = File.ReadAllText(path);

var ivBytes = Convert.FromBase64String(salt);
var keyBytes = new ASCIIEncoding().GetBytes(key);
var ivBytes = Convert.FromBase64String(Salt);
var keyBytes = new ASCIIEncoding().GetBytes(Key);

byte[] toEncrypt = new ASCIIEncoding().GetBytes(Convert.ToBase64String(new ASCIIEncoding().GetBytes(content)));

Expand All @@ -399,8 +402,8 @@ private void DecryptFile(string path)
{
var content = File.ReadAllText(path);

var ivBytes = Convert.FromBase64String(salt);
var keyBytes = new ASCIIEncoding().GetBytes(key);
var ivBytes = Convert.FromBase64String(Salt);
var keyBytes = new ASCIIEncoding().GetBytes(Key);

var toDecryptArray = Convert.FromBase64String(content);

Expand Down

0 comments on commit 530cd6b

Please sign in to comment.