string hashMethod = ""; if (sha1.Checked) { hashMethod = "SHA1"; } else { hashMethod = "MD5"; } string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password.Text, hashMethod); result.Text="<credentials passwordFormat=/"" + hashMethod +"/">" + " <user name=/"" + userName.Text + "/" password=/"" + hashedPassword + "/">" + "</credentials>";