private static String escape(String string) {
        StringBuilder sb = new StringBuilder((int) (string.length() * 1.1));
        for (int i = 0; i < string.length(); i++) {
            char c = string.charAt(i);
            switch (c) {
            case ',':
                sb.append("=2C");
                break;
            case '=':
                sb.append("=3D");
                break;
            default:
                sb.append(c);
                break;
            }
        }
        return sb.toString();
    }
private static String escape ( String string ) { StringBuilder sb = new StringBuilder ( ( int ) ( string . length ( ) * 1.1 ) ) ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { char c = string . charAt ( i ) ; switch ( c ) { case ',' : sb . append ( "=2C" ) ; break ; case '=' : sb . append ( "=3D" ) ; break ; default : sb . append ( c ) ; break ; } } return sb . toString ( ) ; }
Escapes usernames or passwords for SASL SCRAM-SHA1.
<p>
According to RFC 5802 § 5.1 'n:'
"The characters ',' or '=' in usernames are sent as '=2C' and '=3D' respectively."
</p>

@param string
@return the escaped string