aquamoon blog http://aquamoonblog.wordpress.com/?p=14 https://aquamoonblog.wordpress.com/2013/07/26/creating-a-highly-scalable-technology-stack-capable-of-running-on-your-own-hardware-or-on-most-cloud-based-infrastructure-providers/ System Architecture C# cloud datacentre nosql Open Hardware Standards relational technology stack Creating a highly scalable technology stack capable of running on your own hardware or on most cloud based infrastructure providers I created this proposed architectural diagram as a starting point to developing a highly scalable and flexible technology stack that can be run on your own hardware or on cloud based infrastructure providers. All coding for application built for this stack is done in C#, from mobile apps running on 3 different platforms to the [&#8230;]<img alt="" border="0" src="https://pixel.wp.com/b.gif?host=aquamoonblog.wordpress.com&#038;blog=55305030&#038;post=14&#038;subd=aquamoonblog&#038;ref=&#038;feed=1" width="1" height="1" /> Fri, 26 Jul 2013 11:56:40 Z https://aquamoonblog.wordpress.com/2013/07/26/creating-a-highly-scalable-technology-stack-capable-of-running-on-your-own-hardware-or-on-most-cloud-based-infrastructure-providers/#respond Vicente Da Silva <p><a href="https://aquamoonblog.files.wordpress.com/2013/07/data-centre-architecture.png"><img class="alignnone size-full wp-image-12" alt="Highly scalable technology stack" src="https://aquamoonblog.files.wordpress.com/2013/07/data-centre-architecture.png?w=580&#038;h=326" width="580" height="326" srcset="https://aquamoonblog.files.wordpress.com/2013/07/data-centre-architecture.png?w=580&amp;h=326 580w, https://aquamoonblog.files.wordpress.com/2013/07/data-centre-architecture.png?w=1160&amp;h=652 1160w, https://aquamoonblog.files.wordpress.com/2013/07/data-centre-architecture.png?w=150&amp;h=84 150w, https://aquamoonblog.files.wordpress.com/2013/07/data-centre-architecture.png?w=300&amp;h=169 300w, https://aquamoonblog.files.wordpress.com/2013/07/data-centre-architecture.png?w=768&amp;h=432 768w, https://aquamoonblog.files.wordpress.com/2013/07/data-centre-architecture.png?w=1024&amp;h=576 1024w" sizes="(max-width: 580px) 100vw, 580px" /></a></p> <p><span style="color:#000000;">I created this proposed architectural diagram as a starting point to developing a highly scalable and flexible technology stack that can be run on your own hardware or on cloud based infrastructure providers. All coding for application built for this stack is done in C#, from mobile apps running on 3 different platforms to the web apps / web services. This still needs a lot more research but I would like to get some feedback on how well this stack would forefill the requirements of needing to be highly scalable and where applications developed to run on it can be written in a single language, namely C#. References to the various technologies are shown below.</span></p> <p><span style="color:#000000;">Facebook Open Hardware Standards: </span><a href="http://www.opencompute.org/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://www.opencompute.org</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">OpenNebula: </span><a href="http://opennebula.org/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://opennebula.org/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">CF Engine: </span><a href="http://cfengine.com/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://cfengine.com/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">PostgreSQL: </span><a href="http://www.postgresql.org/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://www.postgresql.org/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">MongoDB: </span><a href="http://www.mongodb.org/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://www.mongodb.org/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">CouchDB: </span><a href="http://couchdb.apache.org/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://couchdb.apache.org/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">Hadoop: </span><a href="http://hadoop.apache.org/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://hadoop.apache.org/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">Redis: </span><a href="http://redis.io/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://redis.io/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">Memcached: </span><a href="http://memcached.org/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://memcached.org/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">Riak: </span><a href="http://basho.com/riak/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://basho.com/riak/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">ServiceStack: </span><a href="http://www.servicestack.net/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://www.servicestack.net/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">Nginx: </span><a href="http://nginx.com/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://nginx.com/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">ASP MVC: </span><a href="http://www.asp.net/mvc"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://www.asp.net/mvc</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">Xamarin: </span><a href="http://xamarin.com/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://xamarin.com/</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">Visual Studio: </span><a href="http://www.microsoft.com/visualstudio"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://www.microsoft.com/visualstudio</span></span></a></p> <p><span style="color:#000000;font-family:Calibri;font-size:medium;">.NET: </span><a href="http://www.microsoft.com/net/"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://www.microsoft.com/net/</span></span></a></p> <p><span style="color:#000000;">Mono: </span><a href="http://www.mono-project.com/Main_Page"><span style="text-decoration:underline;"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">http://www.mono-project.com/Main_Page</span></span></a></p><br /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aquamoonblog.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aquamoonblog.wordpress.com/14/" /></a> <img alt="" border="0" src="https://pixel.wp.com/b.gif?host=aquamoonblog.wordpress.com&#038;blog=55305030&#038;post=14&#038;subd=aquamoonblog&#038;ref=&#038;feed=1" width="1" height="1" /> https://aquamoonblog.wordpress.com/2013/07/26/creating-a-highly-scalable-technology-stack-capable-of-running-on-your-own-hardware-or-on-most-cloud-based-infrastructure-providers/feed/ 0 aquamoonblog Highly scalable technology stack 2013-07-26 11:56 +00:00 2013-07-26 11:56 +00:00 http://aquamoonblog.wordpress.com/?p=4 https://aquamoonblog.wordpress.com/2013/07/15/decrypting-a-dotnetnuke-password-c/ Random Coding ASP Membership ASP.NET DotNetNuke Encryption Key Password String (C++) SymmetricCryptography Decrypting a DotNetNuke password (C#) Recently I needed to decrypt a DotNetNuke password for a website I manage. After looking around the internet and using bits and pieces of code and tips I wrote the following code which allows one to decrypt a DotNetNuke password, in fact it will work for any web site using the ASP Membership framework configured [&#8230;]<img alt="" border="0" src="https://pixel.wp.com/b.gif?host=aquamoonblog.wordpress.com&#038;blog=55305030&#038;post=4&#038;subd=aquamoonblog&#038;ref=&#038;feed=1" width="1" height="1" /> Mon, 15 Jul 2013 10:56:11 Z https://aquamoonblog.wordpress.com/2013/07/15/decrypting-a-dotnetnuke-password-c/#comments Vicente Da Silva <p>Recently I needed to decrypt a DotNetNuke password for a website I manage. After looking around the internet and using bits and pieces of code and tips I wrote the following code which allows one to decrypt a DotNetNuke password, in fact it will work for any web site using the ASP Membership framework configured for 3DES encryption. Note that this was written fairly quickly so it may not follow the best coding practises.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; using Utility; namespace Temp { class Program { static void Main(string[] args) { //replace below with your key found in web.config file of DNN installation var keyString = "7720BDAF296F5840DBD6189F3A1FA5BFEC1430D8085B1ECC"; int discarded = 0; var key = HexEncoding.GetBytes(keyString, out discarded); var iv = new byte[8]; //replace below with salt found in [aspnet_Membership] table [PasswordSalt] of user whose password you need to decrypt var saltString = "7JhHSow7bPPYY65oIpCUVw=="; var salt = Convert.FromBase64String(saltString); string saltHex = HexEncoding.ToString(salt); //replace below with password found in [aspnet_Membership] table [Password] of user whose password you need to decrypt var valueString = "4gVdMifvbg7Fb3jZfzfy5qmesl73f14bZq/lJyp82fg="; var value = Convert.FromBase64String(valueString); Utilities.Crypto.SymmetricCryptography&lt;TripleDESCryptoServiceProvider&gt; sec = new Utilities.Crypto.SymmetricCryptography&lt;TripleDESCryptoServiceProvider&gt;(key, iv); //remove salt from result byte[] dec2 = sec.Decrypt(value); byte[] dec3 = new byte[dec2.Length - salt.Length]; int j = 0; for (int i = 0; i &lt; dec2.Length; i++) { if (i &gt; salt.Length - 1) { dec3[j] = dec2[i]; j++; } } //count null chars j = 0; for (int i = 0; i &lt; dec3.Length; i++) { if (dec3[i] == 0) { j++; } } //remove null chars byte[] dec4 = new byte[dec3.Length - j]; j=0; for (int i = 0; i &lt; dec3.Length; i++) { if (dec3[i] != 0) { dec4[j] = dec3[i]; j++; } } string password1 = Encoding.UTF8.GetString(dec4); } } } </code></pre> <p>Below is the code for SymmetricCryptography (I found this on the net)</p> <pre><code>using System; using System.IO; using System.Text; using System.Security; using System.Security.Cryptography; using System.Runtime.InteropServices; namespace Utilities.Crypto { class SymmetricCryptography&lt;T&gt; where T : SymmetricAlgorithm, new() { #region Fields private T _provider = new T(); private UTF8Encoding _utf8 = new UTF8Encoding(); #endregion Fields #region Properties private byte[] _key; public byte[] Key { get { return _key; } set { _key = value; } } private byte[] _iv; public byte[] IV { get { return _iv; } set { _iv = value; } } #endregion Properties #region Constructors public SymmetricCryptography() { _provider.GenerateKey(); _key = _provider.Key; _provider.GenerateIV(); _iv = _provider.IV; } public SymmetricCryptography(byte[] key, byte[] iv) { _key = key; if (iv == null) { _provider.Key = key; _provider.GenerateIV(); iv = _provider.IV; } _iv = iv; } #endregion Constructors #region Byte Array Methods public byte[] Encrypt(byte[] input) { return Encrypt(input, _key, _iv); } public byte[] Decrypt(byte[] input) { return Decrypt(input, _key, _iv); } public byte[] Encrypt(byte[] input, byte[] key, byte[] iv) { return Transform(input, _provider.CreateEncryptor(key, iv)); } public byte[] Decrypt(byte[] input, byte[] key, byte[] iv) { return Transform(input, _provider.CreateDecryptor(key, iv)); } #endregion Byte Array Methods #region String Methods public string Encrypt(string text) { return Encrypt(text, _key, _iv); } public string Decrypt(string text) { return Decrypt(text, _key, _iv); } public string Encrypt(string text, byte[] key, byte[] iv) { byte[] output = Transform(_utf8.GetBytes(text), _provider.CreateEncryptor(key, iv)); return Convert.ToBase64String(output); } public string Decrypt(string text, byte[] key, byte[] iv) { byte[] output = Transform(Convert.FromBase64String(text), _provider.CreateDecryptor(key, iv)); return _utf8.GetString(output); } #endregion String Methods #region SecureString Methods public byte[] Encrypt(SecureString input) { return Encrypt(input, _key, _iv); } public void Decrypt(byte[] input, out SecureString output) { Decrypt(input, out output, _key, _iv); } public byte[] Encrypt(SecureString input, byte[] key, byte[] iv) { // defensive argument checking if (input == null) throw new ArgumentNullException("input"); IntPtr inputPtr = IntPtr.Zero; try { // copy the SecureString to an unmanaged BSTR // and get back the pointer to the memory location inputPtr = Marshal.SecureStringToBSTR(input); if (inputPtr == IntPtr.Zero) throw new InvalidOperationException("Unable to allocate" + "necessary unmanaged resources."); char[] inputBuffer = new char[input.Length]; try { // pin the buffer array so the GC doesn't move it while we // are doing an unmanaged memory copy, but make sure we // release the pin when we are done so that the CLR can do // its thing later GCHandle handle = GCHandle.Alloc(inputBuffer, GCHandleType.Pinned); try { Marshal.Copy(inputPtr, inputBuffer, 0, input.Length); } finally { handle.Free(); } // encode the input as UTF8 first so that we have a // way to explicitly "flush" the byte array afterwards byte[] utf8Buffer = _utf8.GetBytes(inputBuffer); try { return Encrypt(utf8Buffer, key, iv); } finally { Array.Clear(utf8Buffer, 0, utf8Buffer.Length); } } finally { Array.Clear(inputBuffer, 0, inputBuffer.Length); } } finally { // because we are using unmanaged resources, we *must* // explicitly deallocate those resources ourselves if (inputPtr != IntPtr.Zero) Marshal.ZeroFreeBSTR(inputPtr); } } public void Decrypt(byte[] input, out SecureString output, byte[] key, byte[] iv) { byte[] decryptedBuffer = null; try { // do our normal decryption of a byte array decryptedBuffer = Decrypt(input, key, iv); char[] outputBuffer = null; try { // convert the decrypted array to an explicit // character array that we can "flush" later outputBuffer = _utf8.GetChars(decryptedBuffer); // Create the result and copy the characters output = new SecureString(); try { for (int i = 0; i &lt; outputBuffer.Length; i++) output.AppendChar(outputBuffer[i]); return; } finally { output.MakeReadOnly(); } } finally { if (outputBuffer != null) Array.Clear(outputBuffer, 0, outputBuffer.Length); } } finally { if (decryptedBuffer != null) Array.Clear(decryptedBuffer, 0, decryptedBuffer.Length); } } #endregion SecureString Methods #region Stream Methods public void Encrypt(Stream input, Stream output) { Encrypt(input, output, _key, _iv); } public void Decrypt(Stream input, Stream output) { Decrypt(input, output, _key, _iv); } public void Encrypt(Stream input, Stream output, byte[] key, byte[] iv) { TransformStream(true, ref input, ref output, key, iv); } public void Decrypt(Stream input, Stream output, byte[] key, byte[] iv) { TransformStream(false, ref input, ref output, key, iv); } #endregion Stream Methods #region Private Methods private byte[] Transform(byte[] input, ICryptoTransform CryptoTransform) { // create the necessary streams MemoryStream memStream = new MemoryStream(); CryptoStream cryptStream = new CryptoStream(memStream, CryptoTransform, CryptoStreamMode.Write); // transform the bytes as requested cryptStream.Write(input, 0, input.Length); cryptStream.FlushFinalBlock(); // Read the memory stream and // convert it back into byte array memStream.Position = 0; byte[] result = memStream.ToArray(); // close and release the streams memStream.Close(); cryptStream.Close(); // hand back the encrypted buffer return result; } private void TransformStream(bool encrypt, ref Stream input, ref Stream output, byte[] key, byte[] iv) { // defensive argument checking if (input == null) throw new ArgumentNullException("input"); if (output == null) throw new ArgumentNullException("output"); if (!input.CanRead) throw new ArgumentException("Unable to read from the input" + "Stream.", "input"); if (!output.CanWrite) throw new ArgumentException("Unable to write to the output" + "Stream.", "output"); // make the buffer just large enough for // the portion of the stream to be processed byte[] inputBuffer = new byte[input.Length - input.Position]; // read the stream into the buffer input.Read(inputBuffer, 0, inputBuffer.Length); // transform the buffer byte[] outputBuffer = encrypt ? Encrypt(inputBuffer, key, iv) : Decrypt(inputBuffer, key, iv); // write the transformed buffer to our output stream output.Write(outputBuffer, 0, outputBuffer.Length); } #endregion Private Methods } } </code></pre> <p>Below is the code for HexEncoding(I found this on the net)</p> <pre><code>using System; using System.Text; namespace Utility { /// &lt;summary&gt; /// Summary description for HexEncoding. /// &lt;/summary&gt; public class HexEncoding { public HexEncoding() { // // TODO: Add constructor logic here // } public static int GetByteCount(string hexString) { int numHexChars = 0; char c; // remove all none A-F, 0-9, characters for (int i=0; i&lt;hexString.Length; i++) { c = hexString[i]; if (IsHexDigit(c)) numHexChars++; } // if odd number of characters, discard last character if (numHexChars % 2 != 0) { numHexChars--; } return numHexChars / 2; // 2 characters per byte } /// &lt;summary&gt; /// Creates a byte array from the hexadecimal string. Each two characters are combined /// to create one byte. First two hexadecimal characters become first byte in returned array. /// Non-hexadecimal characters are ignored. /// &lt;/summary&gt; /// &lt;param name="hexString"&gt;string to convert to byte array&lt;/param&gt; /// &lt;param name="discarded"&gt;number of characters in string ignored&lt;/param&gt; /// &lt;returns&gt;byte array, in the same left-to-right order as the hexString&lt;/returns&gt; public static byte[] GetBytes(string hexString, out int discarded) { discarded = 0; string newString = ""; char c; // remove all none A-F, 0-9, characters for (int i=0; i&lt;hexString.Length; i++) { c = hexString[i]; if (IsHexDigit(c)) newString += c; else discarded++; } // if odd number of characters, discard last character if (newString.Length % 2 != 0) { discarded++; newString = newString.Substring(0, newString.Length-1); } int byteLength = newString.Length / 2; byte[] bytes = new byte[byteLength]; string hex; int j = 0; for (int i=0; i&lt;bytes.Length; i++) { hex = new String(new Char[] {newString[j], newString[j+1]}); bytes[i] = HexToByte(hex); j = j+2; } return bytes; } public static string ToString(byte[] bytes) { string hexString = ""; for (int i=0; i&lt;bytes.Length; i++) { hexString += bytes[i].ToString("X2"); } return hexString; } /// &lt;summary&gt; /// Determines if given string is in proper hexadecimal string format /// &lt;/summary&gt; /// &lt;param name="hexString"&gt;&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; public static bool InHexFormat(string hexString) { bool hexFormat = true; foreach (char digit in hexString) { if (!IsHexDigit(digit)) { hexFormat = false; break; } } return hexFormat; } /// &lt;summary&gt; /// Returns true is c is a hexadecimal digit (A-F, a-f, 0-9) /// &lt;/summary&gt; /// &lt;param name="c"&gt;Character to test&lt;/param&gt; /// &lt;returns&gt;true if hex digit, false if not&lt;/returns&gt; public static bool IsHexDigit(Char c) { int numChar; int numA = Convert.ToInt32('A'); int num1 = Convert.ToInt32('0'); c = Char.ToUpper(c); numChar = Convert.ToInt32(c); if (numChar &gt;= numA &amp;&amp; numChar &lt; (numA + 6)) return true; if (numChar &gt;= num1 &amp;&amp; numChar &lt; (num1 + 10)) return true; return false; } /// &lt;summary&gt; /// Converts 1 or 2 character string into equivalant byte value /// &lt;/summary&gt; /// &lt;param name="hex"&gt;1 or 2 character string&lt;/param&gt; /// &lt;returns&gt;byte&lt;/returns&gt; private static byte HexToByte(string hex) { if (hex.Length &gt; 2 || hex.Length &lt;= 0) throw new ArgumentException("hex must be 1 or 2 characters in length"); byte newByte = byte.Parse(hex, System.Globalization.NumberStyles.HexNumber); return newByte; } } } </code></pre><br /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aquamoonblog.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aquamoonblog.wordpress.com/4/" /></a> <img alt="" border="0" src="https://pixel.wp.com/b.gif?host=aquamoonblog.wordpress.com&#038;blog=55305030&#038;post=4&#038;subd=aquamoonblog&#038;ref=&#038;feed=1" width="1" height="1" /> https://aquamoonblog.wordpress.com/2013/07/15/decrypting-a-dotnetnuke-password-c/feed/ 2 aquamoonblog 2013-07-15 10:56 +00:00 2013-07-15 10:56 +00:00