public static String encrypt(String passwordText, String codeText) { if (passwordText == "" || codeText == "") { return(""); } try { String encryptOne = hmacSHA256(passwordText, codeText); Debug.Print("encryptOne: " + encryptOne); String encryptTwo = hmacSHA256(encryptOne, PasswordUtil.getKeyPassword()); Debug.Print("encryptTwo: " + encryptTwo); StringBuilder result = new StringBuilder(encryptTwo); if (ConfigurationManager.AppSettings["with_symbol"] == "1") { processSomeCharToCharacter(encryptTwo, result); } processSomeCharToNumber(result); if (ConfigurationManager.AppSettings["first_capital_letter"] == "1") { processFirstCapitalLetterToUpperCase(result); } String code32 = result.ToString(); String code16; int passwordLength = int.Parse(ConfigurationManager.AppSettings["password_length"]); code16 = code32.Substring(0, passwordLength); return(code16); } catch (Exception e) { throw new Exception("Error occured while encrypting password " + passwordText + " with code " + codeText, e); } }