Example #1
0
        private void frmInterface_Load(object sender, EventArgs e)
        {
            if (ForceToClose)
            {
                this.Close();
            }
            using (RegistryKey Key = Registry.LocalMachine.OpenSubKey(@"Software\Autodesk\AutoCAD\R17.2\ACAD-7001:409\Applications\ATEND", false))
            {
                if (Key != null)
                {
                    lblPath.Text = Key.GetValue("LOADER").ToString();
                    Path         = Key.GetValue("LOADER").ToString();

                    lblVersion.Text = Key.GetValue("VERSION").ToString();
                    Version         = Key.GetValue("VERSION").ToString();
                }
            }
            Path    = Path.Replace("Atend.dll", "");
            Version = Version.Substring(6, 7).Replace(".", "");
            Atend.Global.Utility.UInterface inter = new Atend.Global.Utility.UInterface();

            string plainText          = inter.GetInterface();
            string passPhrase         = Version;
            string saltValue          = Version;
            string hashAlgorithm      = "SHA1";
            int    passwordIterations = 2;
            string initVector         = "@1B2c3D4e5F6g7H8";
            int    keySize            = 256;
            string EncryptText        = inter.EnInterface(plainText, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize);

            lblRequest.Text = EncryptText;

            FileStream stream = new FileStream(string.Format(@"{0}LICENCE.ATND", Path), System.IO.FileMode.Create);

            System.Text.ASCIIEncoding a = new ASCIIEncoding();
            byte[] reader = a.GetBytes(EncryptText); //Convert.FromBase64String(EncryptText);
            stream.Write(reader, 0, reader.Length);
            stream.Close();
        }