예제 #1
0
        private void ResetPassword(Int64 UserID)
        {

            string plainText = DateTime.Now.ToString("yyyyMMddhhmmss");    // original plaintext
            //string  cipherText = System.Configuration.ConfigurationManager.AppSettings["RegistrationKey"].ToString();	// encrypted text
            string passPhrase = CompanyDetails.TIN; // can be any string
            string initVector = "%@skmelaT3rsh1t!"; // must be 16 bytes

            // Before encrypting data, we will append plain text to a random
            // salt value, which will be between 4 and 8 bytes long (implicitly
            // used defaults).
            AceSoft.Cryptor clsCryptor = new AceSoft.Cryptor(passPhrase, initVector);
            string strPassword = clsCryptor.Encrypt(plainText);
            strPassword = strPassword.Length > 8 ? strPassword.Substring(1, 8) : strPassword;

            AccessUser clsAccessUser = new AccessUser();
            clsAccessUser.UpdatePassword(UserID, strPassword);
            clsAccessUser.CommitAndDispose();

            string stScript = "<Script>";
            stScript += "window.alert('Please advise the user of the new password: "******"')";
            stScript += "</Script>";
            Response.Write(stScript);	
        }