// Suitable for C # language // Need to import the following namespace before use: use system.web.security; // The first parameter is a string that needs to be encrypted, the second parameter is encrypted format (only SHA1 and MD5 two species, may optionally one) public string EncryptPassword (string PasswordString, string passwordFormat) {string EncryptPassword = null; if ( "SHA1" .Equals (passwordFormat)) {EncryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile (PasswordString, "SHA1");} else if ( "MD5" .Equals (passwordFormat)) {EncryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile (PasswordString, "MD5");} else {EncryptPassword = PasswordString;} return EncryptPassword;}