diff --git a/CryptNote - Very First Project/.vs/CryptNote/v14/.suo b/CryptNote - Very First Project/.vs/CryptNote/v14/.suo new file mode 100644 index 0000000..7982af2 Binary files /dev/null and b/CryptNote - Very First Project/.vs/CryptNote/v14/.suo differ diff --git a/CryptNote - Very First Project/CryptNote.sln b/CryptNote - Very First Project/CryptNote.sln new file mode 100644 index 0000000..f6a8a20 --- /dev/null +++ b/CryptNote - Very First Project/CryptNote.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CryptNote", "Journal\CryptNote.csproj", "{74D8C056-DD54-4548-85F1-E0FC7DD16B7A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {74D8C056-DD54-4548-85F1-E0FC7DD16B7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74D8C056-DD54-4548-85F1-E0FC7DD16B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74D8C056-DD54-4548-85F1-E0FC7DD16B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74D8C056-DD54-4548-85F1-E0FC7DD16B7A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/CryptNote - Very First Project/Journal/32bitEncryption.cs b/CryptNote - Very First Project/Journal/32bitEncryption.cs new file mode 100644 index 0000000..a3c15fe --- /dev/null +++ b/CryptNote - Very First Project/Journal/32bitEncryption.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Security.Cryptography; +using System.IO; +namespace Journal +{ + public class _32bitEncryption + { + string Plain_Text; + byte[] Encrypted_Bytes; + string Encrypted_sting; + //This class here the Rijndael is what will have most all of the methods we need to do aes encryption. + //When this is called it will create both a key and Initialization Vector to use. + RijndaelManaged Crypto = new RijndaelManaged(); + //This is just here to convert the Encrypted byte array to a string for viewing purposes. + UTF8Encoding UTF = new UTF8Encoding(); + public _32bitEncryption() { } + public _32bitEncryption(string _text, byte[] Key, byte[] IV) + { + Plain_Text = _text; + Crypto.Key = Key; + Crypto.IV = IV; + Encrypted_Bytes = encrypt_function(Plain_Text, Crypto.Key, Crypto.IV); + Encrypted_sting = ReturnEncrtpedbytetostring(); + } + #region GettersAndSetters + public string ReturnEncrtpedbytetostring() + { + return UTF.GetString(Encrypted_Bytes); + } + public string ReturnEncrtpedbytetostring(byte[] _tmp) + { + return UTF.GetString(_tmp); + } + public RijndaelManaged GetCrypto() + { + return Crypto; + } + public void SetCrypto(RijndaelManaged _tmp) + { + Crypto = _tmp; + } + public void SetText(string _str) + { + Plain_Text = _str; + } + public string GetText() + { + return Plain_Text; + } + public void SetEncrptedText(string _str) + { + Encrypted_sting = _str; + } + public string GetEncryptrdText() + { + return Encrypted_sting; + } + public byte[] GetEncrptBytes() + { + return Encrypted_Bytes; + } + #endregion + public byte[] encrypt_function(string plainText, byte[] Key, byte[] IV) + + { + byte[] initVectorBytes = IV; + byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText); + PasswordDeriveBytes password = new PasswordDeriveBytes(Properties.Settings.Default.Password, null); + byte[] keyBytes = password.GetBytes(256 / 8); + RijndaelManaged symmetricKey = new RijndaelManaged(); + symmetricKey.Padding = PaddingMode.Zeros; + symmetricKey.Mode = CipherMode.CBC; + ICryptoTransform encryptor = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes); + MemoryStream memoryStream = new MemoryStream(); + CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write); + cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); + cryptoStream.FlushFinalBlock(); + byte[] cipherTextBytes = memoryStream.ToArray(); + memoryStream.Close(); + cryptoStream.Close(); + return cipherTextBytes; + #region Doesnt work + //RijndaelManaged Crypto = null; + //MemoryStream MemStream = null; + ////I crypto transform is used to perform the actual decryption vs encryption, hash function are a version of crypto transforms. + //ICryptoTransform Encryptor = null; + ////Crypto streams allow for encryption in memory. + //CryptoStream Crypto_Stream = null; + //System.Text.UTF8Encoding Byte_Transform = new System.Text.UTF8Encoding(); + ////Just grabbing the bytes since most crypto functions need bytes. + //byte[] PlainBytes = Byte_Transform.GetBytes(Plain_Text); + //try + //{ + // Crypto = new RijndaelManaged(); + // Crypto.Key = Key; + // Crypto.IV = IV; + // MemStream = new MemoryStream(); + // //Calling the method create encryptor method Needs both the Key and IV these have to be from the original Rijndael call + // //If these are changed nothing will work right. + // Encryptor = Crypto.CreateEncryptor(Crypto.Key, Crypto.IV); + // //The big parameter here is the cryptomode.write, you are writing the data to memory to perform the transformation + // Crypto_Stream = new CryptoStream(MemStream, Encryptor, CryptoStreamMode.Write); + // //The method write takes three params the data to be written (in bytes) the offset value (int) and the length of the stream (int) + // Crypto_Stream.Write(PlainBytes, 0, PlainBytes.Length); + //} + //finally + //{ + // //if the crypto blocks are not clear lets make sure the data is gone + // if (Crypto != null) + // Crypto.Clear(); + // //Close because of my need to close things then done. + // Crypto_Stream.Close(); + //} + ////Return the memory byte array + //return MemStream.ToArray(); + //if (plainText == null || plainText.Length <= 0) + // throw new ArgumentNullException("plainText"); + //if (Key == null || Key.Length <= 0) + // throw new ArgumentNullException("Key"); + //if (IV == null || IV.Length <= 0) + // throw new ArgumentNullException("IV"); + //byte[] encrypted; + //// Create an Aes object + //// with the specified key and IV. + //using (Aes aesAlg = Aes.Create()) + //{ + // aesAlg.Key = Key; + // aesAlg.IV = IV; + + // // Create a decrytor to perform the stream transform. + // ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV); + + // // Create the streams used for encryption. + // using (MemoryStream msEncrypt = new MemoryStream()) + // { + // using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)) + // { + // using (StreamWriter swEncrypt = new StreamWriter(csEncrypt)) + // { + + // //Write all data to the stream. + // swEncrypt.Write(plainText); + // } + // encrypted = msEncrypt.ToArray(); + // } + // } + //} + + + // Return the encrypted bytes from the memory stream. + //return encrypted; + #endregion + } + public string decrypt_function(byte[] cipherText, byte[] Key, byte[] IV ) + { + + byte[] initVectorBytes = IV; + byte[] cipherTextBytes = cipherText; + PasswordDeriveBytes password = new PasswordDeriveBytes(Properties.Settings.Default.Password, null); + byte[] keyBytes = password.GetBytes(256 / 8); + RijndaelManaged symmetricKey = new RijndaelManaged(); + symmetricKey.Padding = PaddingMode.Zeros; + symmetricKey.Mode = CipherMode.CBC; + ICryptoTransform decryptor = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes); + MemoryStream memoryStream = new MemoryStream(cipherTextBytes); + CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read); + byte[] plainTextBytes = new byte[cipherTextBytes.Length]; + int decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length); + memoryStream.Close(); + cryptoStream.Close(); + return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount); + } + + public byte[] GetBytes(string str) + { + byte[] bytes = new byte[str.Length * sizeof(char)]; + Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); + return bytes; + } + } +} + diff --git a/CryptNote - Very First Project/Journal/64bitCreateAccount.Designer.cs b/CryptNote - Very First Project/Journal/64bitCreateAccount.Designer.cs new file mode 100644 index 0000000..ba4a054 --- /dev/null +++ b/CryptNote - Very First Project/Journal/64bitCreateAccount.Designer.cs @@ -0,0 +1,187 @@ +namespace Journal +{ + partial class _64bitCreateAccount + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.InfoText = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.PasswordText = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.VerifyTextBox = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.UserPasMatch = new System.Windows.Forms.Label(); + this.OkButton = new System.Windows.Forms.Button(); + this.CancelButton = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // InfoText + // + this.InfoText.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.InfoText.Enabled = false; + this.InfoText.Location = new System.Drawing.Point(12, 217); + this.InfoText.Multiline = true; + this.InfoText.Name = "InfoText"; + this.InfoText.ReadOnly = true; + this.InfoText.Size = new System.Drawing.Size(258, 49); + this.InfoText.TabIndex = 33; + this.InfoText.Text = "CrypteNote will like to remind you that its not the safiest program. We are only " + + "using a 64-bit encrpytion. Best regards from ZeroUnderscoreZero\r\n"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(18, 112); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(25, 13); + this.label1.TabIndex = 34; + this.label1.Text = "Key"; + // + // PasswordText + // + this.PasswordText.ImeMode = System.Windows.Forms.ImeMode.Off; + this.PasswordText.Location = new System.Drawing.Point(12, 128); + this.PasswordText.MaxLength = 64; + this.PasswordText.Name = "PasswordText"; + this.PasswordText.PasswordChar = '*'; + this.PasswordText.Size = new System.Drawing.Size(243, 20); + this.PasswordText.TabIndex = 35; + this.PasswordText.Enter += new System.EventHandler(this.PasswordText_Enter); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(18, 157); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(62, 13); + this.label2.TabIndex = 36; + this.label2.Text = "Retype Key"; + // + // VerifyTextBox + // + this.VerifyTextBox.Location = new System.Drawing.Point(12, 173); + this.VerifyTextBox.MaxLength = 64; + this.VerifyTextBox.Name = "VerifyTextBox"; + this.VerifyTextBox.PasswordChar = '*'; + this.VerifyTextBox.Size = new System.Drawing.Size(243, 20); + this.VerifyTextBox.TabIndex = 37; + this.VerifyTextBox.Enter += new System.EventHandler(this.VerifyTextBox_Enter); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Times New Roman", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(56, 77); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(136, 31); + this.label3.TabIndex = 38; + this.label3.Text = "Create Key"; + // + // UserPasMatch + // + this.UserPasMatch.AutoSize = true; + this.UserPasMatch.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.UserPasMatch.ForeColor = System.Drawing.Color.Red; + this.UserPasMatch.Location = new System.Drawing.Point(60, 196); + this.UserPasMatch.Name = "UserPasMatch"; + this.UserPasMatch.Size = new System.Drawing.Size(146, 18); + this.UserPasMatch.TabIndex = 39; + this.UserPasMatch.Text = "Keys do NOT match!"; + this.UserPasMatch.Visible = false; + // + // OkButton + // + this.OkButton.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray; + this.OkButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.OkButton.Location = new System.Drawing.Point(207, 275); + this.OkButton.Name = "OkButton"; + this.OkButton.Size = new System.Drawing.Size(71, 23); + this.OkButton.TabIndex = 40; + this.OkButton.Text = "Ok"; + this.OkButton.UseVisualStyleBackColor = true; + this.OkButton.Click += new System.EventHandler(this.OkButton_Click); + // + // CancelButton + // + this.CancelButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.CancelButton.Location = new System.Drawing.Point(126, 275); + this.CancelButton.Name = "CancelButton"; + this.CancelButton.Size = new System.Drawing.Size(75, 23); + this.CancelButton.TabIndex = 41; + this.CancelButton.Text = "Cancel"; + this.CancelButton.UseVisualStyleBackColor = true; + this.CancelButton.Click += new System.EventHandler(this.CancelButton_Click); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("Times New Roman", 29F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label6.Location = new System.Drawing.Point(44, 9); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(195, 44); + this.label6.TabIndex = 42; + this.label6.Text = "CryptNote"; + // + // _64bitCreateAccount + // + this.AcceptButton = this.OkButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(282, 301); + this.Controls.Add(this.label6); + this.Controls.Add(this.CancelButton); + this.Controls.Add(this.OkButton); + this.Controls.Add(this.UserPasMatch); + this.Controls.Add(this.label3); + this.Controls.Add(this.VerifyTextBox); + this.Controls.Add(this.label2); + this.Controls.Add(this.PasswordText); + this.Controls.Add(this.label1); + this.Controls.Add(this.InfoText); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "_64bitCreateAccount"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Key Creation"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.TextBox InfoText; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox PasswordText; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox VerifyTextBox; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label UserPasMatch; + private System.Windows.Forms.Button OkButton; + public System.Windows.Forms.Button CancelButton; + private System.Windows.Forms.Label label6; + } +} \ No newline at end of file diff --git a/CryptNote - Very First Project/Journal/64bitCreateAccount.cs b/CryptNote - Very First Project/Journal/64bitCreateAccount.cs new file mode 100644 index 0000000..2cf87ee --- /dev/null +++ b/CryptNote - Very First Project/Journal/64bitCreateAccount.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Journal +{ + public partial class _64bitCreateAccount : Form + { + public _64bitCreateAccount() + { + InitializeComponent(); + } + + private void OkButton_Click(object sender, EventArgs e) + { + if(PasswordText.Text.Length < 20 && PasswordText.Text.Length > 0) + { + const string message = + "Are you sure your password is Under 20 characters"; + const string caption = "Set Password"; + var result = MessageBox.Show(message, caption, + MessageBoxButtons.YesNo, + MessageBoxIcon.Question); + + // If the no button was pressed ... + if (result == DialogResult.No) + { + // cancel the closure of the form. + return; + } + + + + } + if(PasswordText.Text.Length == 0) + { + const string message = + "Please enter a password!"; + const string caption = "No Password"; + var result = MessageBox.Show(message, caption, + MessageBoxButtons.YesNo, + MessageBoxIcon.Question); + + // If the no button was pressed ... + + // cancel the closure of the form. + return; + + + } + if (PasswordText.Text == VerifyTextBox.Text) + { + Properties.Settings.Default.Password = PasswordText.Text; + Properties.Settings.Default.Save(); + Close(); + } + else + { + UserPasMatch.Visible = true; + } + } + + private void CancelButton_Click(object sender, EventArgs e) + { + Close(); + } + + private void PasswordText_Enter(object sender, EventArgs e) + { + // OkButton.PerformClick(); + } + + private void VerifyTextBox_Enter(object sender, EventArgs e) + { + if(VerifyTextBox.Text.Length > 0) + OkButton.PerformClick(); + } + } +} diff --git a/CryptNote - Very First Project/Journal/64bitCreateAccount.resx b/CryptNote - Very First Project/Journal/64bitCreateAccount.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/CryptNote - Very First Project/Journal/64bitCreateAccount.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CryptNote - Very First Project/Journal/App.config b/CryptNote - Very First Project/Journal/App.config new file mode 100644 index 0000000..06a3c62 --- /dev/null +++ b/CryptNote - Very First Project/Journal/App.config @@ -0,0 +1,42 @@ + + + + +
+
+ + + + + + + + + Admin + + + + + + Entery.txt + + + 42 + + + + + Admin + + + + + + Entery.txt + + + 42 + + + + \ No newline at end of file diff --git a/CryptNote - Very First Project/Journal/BinaryRW.cs b/CryptNote - Very First Project/Journal/BinaryRW.cs new file mode 100644 index 0000000..3c73011 --- /dev/null +++ b/CryptNote - Very First Project/Journal/BinaryRW.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; + +namespace Journal +{ + class BinaryRW + { + public byte[] ReadBytes(string source) + { + try + { + return File.ReadAllBytes(source); + } + catch (Exception _Exception) + { + Console.WriteLine("Exception caught in process: {0}", + _Exception.ToString()); + } + return null; + } + public bool writeBytes(byte[] _write, string source) + { + try + { + // Open file for reading + System.IO.FileStream _FileStream = + new System.IO.FileStream(source, System.IO.FileMode.Create, + System.IO.FileAccess.Write); + // Writes a block of bytes to this stream using data from + // a byte array. + _FileStream.Write(_write, 0, _write.Length); + + // close file stream + _FileStream.Close(); + + return true; + } + catch (Exception _Exception) + { + // Error + Console.WriteLine("Exception caught in process: {0}", + _Exception.ToString()); + } + + // error occured, return false + return false; + } + public bool writeString(string _write, string _source) + { + if (_write.Length > 0 && _source.Length > 0) + { + File.WriteAllText(_source, _write); + return true; + } + else + return false; + } + public string readString(string _source) + { + try + { + if (_source.Length > 0) + { + string _read = File.ReadAllText(_source); + return _read; + } + } + catch (Exception _Exception) + { + Console.WriteLine("Exception caught in process: {0}", + _Exception.ToString()); + } + return null; + } + } +}