code: public static String encodeAuthAmqPlain(String username, char[] password) {
          Logger logger = LoggerFactory.getLogger(SERVICE_AMQP_PROXY_LOGGER);
          if (logger.isDebugEnabled()) {
              logger.debug(CLASS_NAME + ".encodeAuthAmqPlain(): Username - " + username);
          }
  
          int size =  1  +                   // LOGIN.length
                      5  +                   // LOGIN
                      1  +                   // type-id -- 'S' for LongString
                      4  +                   // username's length
                      username.length() +    // username
                      1  +                   // PASSWORD.length
                      8  +                   // PASSWORD
                      1  +                   // type-id -- 'S' for LongString
                      4  +                   // password's length
                      password.length;       // password
                      
          ByteBuffer buffer = ByteBuffer.allocate(size);
  
          putShortString(buffer, "LOGIN");
          putType(buffer, AmqpType.LONGSTRING);
          putLongString(buffer, username);
  
          putShortString(buffer, "PASSWORD");
          putType(buffer, AmqpType.LONGSTRING);
          putLongString(buffer, new String(password)); // ### TODO: Use char[] directly
          buffer.flip();
          
          // Nulling out the password for security. 
          Arrays.fill(password, '\0');
  
          int len = buffer.remaining();
          StringBuilder builder = new StringBuilder();
          for (int i = 0; i < len; i++)
          {
              builder.append((char)(buffer.get() & 0xff)); 
  
          }
          String s = builder.toString();
          return s;
      }
docs: --------------------- Public Static Methods ---------------------------