Initialize() public method

public Initialize ( ) : void
return void
Example #1
0
        public string MakePassword(string Password)
        {
            string Sha_Password = "";

            SHA1CryptoServiceProvider Crypto = new SHA1CryptoServiceProvider();
            Crypto.Initialize();
            byte[] Result = Crypto.ComputeHash(Encoding.UTF8.GetBytes(Password), 0, Encoding.UTF8.GetByteCount(Password));
            Sha_Password = BitConverter.ToString(Result).Replace("-",string.Empty).ToLower();

            return Sha_Password;
        }
        private static byte[] Process(byte[] data, Operation operation)
        {
            switch (operation)
            {
                case Operation.Convert:
                    return data; 
                case Operation.Sha1:
                    var prov = new SHA1CryptoServiceProvider();
                    prov.Initialize();
                    return prov.ComputeHash(data);
            }

            return null;
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string Username = textBox1.Text;
            string Password = textBox2.Text;

            bool CanContinue = false;

            SHA1CryptoServiceProvider Crypto = new SHA1CryptoServiceProvider();
            Crypto.Initialize();

            Password = BitConverter.ToString(Crypto.ComputeHash(Encoding.UTF8.GetBytes(Password), 0, Encoding.UTF8.GetByteCount(Password))).Replace("-", "").ToLower();

            string Lang = listBox1.SelectedItem != null ? (string)listBox1.SelectedItem : "English";

            string RemoteServer = textBox3.Text;

            string cert = "";

            if (!UsingCertificateServer)
            {
                using (StreamWriter writer = new StreamWriter(cert + @"\SiennaCert.pfx"))
                {
                    writer.WriteLine("Signature: SiennaAuth");
                    writer.WriteLine("<?xml version=\"1.0\"?>");
                    writer.WriteLine("<ClientAuthCertificate xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
                    writer.WriteLine("<Username>" + Username + "</Username>");
                    writer.WriteLine("<Hash>" + Password + "</Hash>");
                    writer.WriteLine("<Sessionkey></Sessionkey>");
                    writer.WriteLine("</ClientAuthCertificate>");
                }

                CanContinue = true;
            }
            else
            {
                WebClient wc = new WebClient();
                string Certificate = wc.DownloadString(CertificateServerUrl + "?username="******"&passhash=" + Password);

                switch (Certificate)
                {
                    case "ERR_INVALID_USERNAME":
                        MessageBox.Show("Error, your username is invalid");
                        break;

                    case "ERR_INVALID_PASSWORD":
                        MessageBox.Show("Error, your password is invalid");
                        break;

                    case "ERR_ACTIVE_BAN":
                        MessageBox.Show("Error, you are banned from the server");
                        break;

                    default:
                        CanContinue = true;
                        break;
                }

                if (CanContinue)
                {
                    using (StreamWriter writer = new StreamWriter(cert + @"\SiennaCert.pfx"))
                    {
                        writer.WriteLine("Signature: SiennaAuth");
                        writer.Write(Certificate);
                    }
                }
            }

            if (CanContinue)
            {
                try
                {
                    Process process = new Process();
                    process.StartInfo.FileName = "rift.exe";
                    process.StartInfo.Arguments = "-u " + Username + " -k " + cert + @"\SiennaCert.pfx -l " + Lang + " -s " + RemoteServer;
                    process.Start();

                    //If ollydbg is not present in the directory the launcher is in it won't start
                    if(File.Exists("ollydbg.exe"))
                    {
                        Process ollydbg = new Process();
                        ollydbg.StartInfo.FileName = "ollydbg.exe";
                        ollydbg.StartInfo.Arguments = "-p " + process.Id;
                        ollydbg.Start();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Error, the launcher must be placed in the game directory");
                }
            }
        }
        private static byte[] PuTTYPassphraseToKey(string passphrase)
        {
            const int HASH_SIZE = 20;
            SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
            byte[] pp = Encoding.UTF8.GetBytes(passphrase);

            byte[] buf = new byte[HASH_SIZE * 2];

            sha1.TransformBlock(new byte[] { 0, 0, 0, 0 }, 0, 4, null, 0);
            sha1.TransformFinalBlock(pp, 0, pp.Length);
            Buffer.BlockCopy(sha1.Hash, 0, buf, 0, HASH_SIZE);
            sha1.Initialize();
            sha1.TransformBlock(new byte[] { 0, 0, 0, 1 }, 0, 4, null, 0);
            sha1.TransformFinalBlock(pp, 0, pp.Length);
            Buffer.BlockCopy(sha1.Hash, 0, buf, HASH_SIZE, HASH_SIZE);
            sha1.Clear();

            byte[] key = new byte[32];
            Buffer.BlockCopy(buf, 0, key, 0, key.Length);
            return key;
        }
Example #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtPass.Text != "" && txtUser.Text != "")
            {
                // Change the RemoteServer to your LoginServers IP address
                string RemoteServer = "sunrisee.no-ip.org:6900";
                string Username = txtUser.Text;
                string Password = txtPass.Text;
                bool CanContinue = false;

                SHA1CryptoServiceProvider Crypto = new SHA1CryptoServiceProvider();
                Crypto.Initialize();
                Password = BitConverter.ToString(Crypto.ComputeHash(Encoding.UTF8.GetBytes(Password), 0, Encoding.UTF8.GetByteCount(Password))).Replace("-", "").ToLower();

                string Lang = "French";
                string cert = "";

                if (!UsingCertificateServer)
                {
                    using (StreamWriter writer = new StreamWriter(cert + @"\SiennaCert.pfx"))
                    {
                        writer.WriteLine("Signature: SiennaAuth");
                        writer.WriteLine("<?xml version=\"1.0\"?>");
                        writer.WriteLine("<ClientAuthCertificate xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
                        writer.WriteLine("<Username>" + Username + "</Username>");
                        writer.WriteLine("<Hash>" + Password + "</Hash>");
                        writer.WriteLine("<Sessionkey></Sessionkey>");
                        writer.WriteLine("</ClientAuthCertificate>");
                    }

                    CanContinue = true;
                }
                else
                {
                    WebClient wc = new WebClient();
                    string Certificate = wc.DownloadString(CertificateServerUrl + "?username="******"&passhash=" + Password);

                    switch (Certificate)
                    {
                        case "ERR_INVALID_USERNAME":
                            MessageBox.Show("Invalid username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        case "ERR_INVALID_PASSWORD":
                            MessageBox.Show("Invalid Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        case "ERR_ACTIVE_BAN":
                            MessageBox.Show("You are banned from the server!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        default:
                            CanContinue = true;
                            break;
                    }

                    if (CanContinue)
                    {
                        using (StreamWriter writer = new StreamWriter(cert + @"\SiennaCert.pfx"))
                        {
                            writer.WriteLine("Signature: SiennaAuth");
                            writer.Write(Certificate);
                        }
                    }
                }

                if (CanContinue)
                {
                    try
                    {
                        Process process = new Process();
                        process.StartInfo.FileName = "rift.exe";
                        process.StartInfo.Arguments = "-u " + Username + " -k " + cert + @"\SiennaCert.pfx -l " + Lang + " -s " + RemoteServer;
                        process.Start();
                        this.Close();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("The launcher must be placed in the game directory", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please provide a valid username & password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #6
0
        private string GetOrderedFitsFileHash()
        {
            if (m_OrderedFitsFileHash == null)
            {
                var hasher = new SHA1CryptoServiceProvider();
                hasher.Initialize();
                var orderedFilesByName = new List<string>(m_FitsFiles);
                orderedFilesByName.Sort();
                byte[] combinedFileNamesBytes = Encoding.UTF8.GetBytes(string.Join("|", orderedFilesByName));
                var hash = hasher.ComputeHash(combinedFileNamesBytes, 0, combinedFileNamesBytes.Length);
                m_OrderedFitsFileHash = Convert.ToBase64String(hash);
            }

            return m_OrderedFitsFileHash;
        }
Example #7
0
        public frmChooseTimeHeaders(Header hdr, string filesHash)
            : this()
        {
            m_FilesHash = filesHash;

            var hasher = new SHA1CryptoServiceProvider();
            hasher.Initialize();
            var orderedCardNames = new List<string>();

            var cursor = hdr.GetCursor();
            while (cursor.MoveNext())
            {
                var card = hdr.FindCard((string)cursor.Key);
                if (card != null)
                {
                    m_AllCards.Add(new HeaderEntry(card));
                }
                orderedCardNames.Add((string) cursor.Key);
            }

            orderedCardNames.Sort();
            byte[] combinedCardNamesBytes = Encoding.UTF8.GetBytes(string.Join("|", orderedCardNames));
            var hash = hasher.ComputeHash(combinedCardNamesBytes, 0, combinedCardNamesBytes.Length);
            m_CardNamesHash = Convert.ToBase64String(hash);

            cbxTimeStamp.Items.AddRange(m_AllCards.ToArray());
            cbxTimeStamp2.Items.AddRange(m_AllCards.ToArray());
            cbxExposure.Items.AddRange(m_AllCards.ToArray());

            cbxExposureUnits.Items.Clear();
            cbxExposureUnits.Items.AddRange(Enum.GetNames(typeof(TangraConfig.ExposureUnit)));

            cbxTimestampType.SelectedIndex = 0;
            cbxExposureUnits.SelectedIndex = 0;

            // End timestamp
            cbxTimestampType2.SelectedIndex = 2;
            cbxTimestampType2.Enabled = false;

            cbxTimeStampFormat.Items.Clear();
            cbxTimeStamp2Format.Items.Clear();
            var formats = new List<object>();
            formats.Add("yyyy-MM-ddTHH:mm:ss.fff");
            formats.Add("dd/MM/yyyy HH:mm:ss.fff");

            if (TangraConfig.Settings.Generic.CustomFITSTimeStampFormats != null)
                formats.AddRange(TangraConfig.Settings.Generic.CustomFITSTimeStampFormats);

            cbxTimeStampFormat.Items.AddRange(formats.ToArray());
            cbxTimeStamp2Format.Items.AddRange(formats.ToArray());
            if (!string.IsNullOrEmpty(TangraConfig.Settings.LastUsed.FitsTimestampFormat))
            {
                int idx = cbxTimeStampFormat.Items.IndexOf(TangraConfig.Settings.LastUsed.FitsTimestampFormat);
                if (idx > -1)
                {
                    cbxTimeStampFormat.SelectedIndex = idx;
                    cbxTimeStamp2Format.SelectedIndex = idx;
                }
            }
            else
            {
                cbxTimeStampFormat.SelectedIndex = 0;
                cbxTimeStamp2Format.SelectedIndex = 0;
            }

            TryIdentifyPreviousConfigApplyingForCurrentFiles();
        }
Example #8
0
        ///
        /// Calculate Hashes
        ///
        internal void ComputeHashes()
        {
            if (Chunks == null || Chunks.Count == 0)
                return;

            Dictionary<string, MemoryMappedFile> files = new Dictionary<string, MemoryMappedFile>();
            Parallel.ForEach(Chunks, new ParallelOptions() { CancellationToken = cancelToken.Token, MaxDegreeOfParallelism = numThreads }, (chunk, state, index) =>
            {
                MemoryMappedFile mms = null;
                byte[] buffer = new byte[(int)pieceLength];
                if (chunk.Length < pieceLength)
                    buffer = new byte[(int)chunk.Length];
                int offset = 0;

                foreach (var source in chunk.Sources)
                {
                    cancelToken.Token.ThrowIfCancellationRequested();
                    lock (files)
                    {
                        if (!files.TryGetValue(source.Filename, out mms))
                        {
                            Debug.WriteLine(String.Format("Opening {0}", source.Filename));
                            files.Add(source.Filename, mms = MemoryMappedFile.CreateFromFile(source.Filename, FileMode.Open));
                        }
                    }

                    MemoryMappedViewStream view = mms.CreateViewStream(source.StartPosition, source.Length, MemoryMappedFileAccess.Read);
                    view.Read(buffer, offset, (int)source.Length);
                    offset += (int)source.Length;
                }

                Debug.WriteLine("Done reading sources");
                using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider())
                {

                    sha1.Initialize();
                    chunk.Hash = sha1.ComputeHash(buffer);
                }

                Debug.WriteLine(String.Format("Computed hash: {0}", String.Join("-", chunk.Hash.Select(h => h.ToString("X2")).ToArray())));
            });

            Parallel.ForEach(files.Values, (x) =>
            {
                x.Dispose();
            });
        }