private Encoder in base64

@param toEncode
String to be encoded
@param flags
flags to encode the String
@return encoded String in base64
971206
private static String privateBase64Encoder(String toEncode, int flags) {
		byte[] data = null;
		try {
			data = toEncode.getBytes("UTF-8");
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		}

		if (flags == -1) {
			flags = Base64.DEFAULT;
		}

		return Base64.encodeToString(data, flags);
	}
269070
public static final String base64Decode(String str, String enc) throws UnsupportedEncodingException {
        if (str == null) {
            return null;
        } else {
            byte data[] = getBytes(str);
            return base64Decode(new String(data, enc));
        }

    }
778674
public static CounterType decodeType(byte flags) {
      switch (flags & 0x03) {
         case WEAK_COUNTER:
            return CounterType.WEAK;
         case BOUNDED_COUNTER:
            return CounterType.BOUNDED_STRONG;
         case UNBOUNDED_COUNTER:
            return CounterType.UNBOUNDED_STRONG;
         default:
            throw log.invalidCounterTypeEncoded();
      }
   }
186496
private static String base64EncodeToString(String s) {
    final byte[] bytes = s.getBytes(StandardCharsets.ISO_8859_1);
    return Base64.encodeBase64String(bytes);
  }
1021248
function InternalCodec(codecOptions, iconv) {
    this.enc = codecOptions.encodingName;
    this.bomAware = codecOptions.bomAware;

    if (this.enc === "base64")
        this.encoder = InternalEncoderBase64;
    else if (this.enc === "cesu8") {
        this.enc = "utf8"; // Use utf8 for decoding.
        this.encoder = InternalEncoderCesu8;

        // Add decoder for versions of Node not supporting CESU-8
        if (Buffer.from('eda0bdedb2a9', 'hex').toString() !== '💩') {
            this.decoder = InternalDecoderCesu8;
            this.defaultCharUnicode = iconv.defaultCharUnicode;
        }
    }
}
491149
function (flagKey) {
  var flags = _.isUndefined(flagKey) ? FLAGS.general : FLAGS[flagKey];

  return !flags ? "" : _.map(flags, function (val, key) {
    return chalk.cyan("--" + key) + ": " + val.desc;
  }).join("\n\n  ");
}
703228
public static String urlEncode(String toEncode) {
        String encoded;
        try {
            encoded = URLEncoder.encode(toEncode, ENCODING);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        // URLEncoder encodes spaces as '+', convert to hex encoding
        encoded = encoded.replaceAll("[+]", "%20");

        // Forwad slashes need not be encoded
        encoded = encoded.replaceAll("%2F", "/");

        return encoded;
    }
955223
public static String base64Decode(String base64Str,String encoding) throws IOException{
		byte [] rawByte = base64Str.getBytes(encoding);
		return new String(SecureUtil.base64Decode(rawByte),encoding);	
	}
411978
public static String encodeBase64(final String data) {
        return Base64.encodeBase64String(data.getBytes(StandardCharsets.UTF_8));
    }
361397
public static String toUnicode(String s, int flags) {
    String[] parts = SEPARATORS_REGEX.split(s);
    for (int i = 0; i < parts.length; i++) {
      if (parts[i].startsWith(PUNYCODE_PREFIX)) {
        parts[i] = decode(parts[i].substring(PUNYCODE_PREFIX.length()));
      }
    }
    return String.join(".", parts);

  }
171825
private void encodeThis() throws IOException {
        if (maps == null || maps.isEmpty()) {
            this.extensionValue = null;
            return;
        }
        DerOutputStream os = new DerOutputStream();
        DerOutputStream tmp = new DerOutputStream();

        for (CertificatePolicyMap map : maps) {
            map.encode(tmp);
        }

        os.write(DerValue.tag_Sequence, tmp);
        this.extensionValue = os.toByteArray();
    }
678795
public static int encodeOctetString(short[] octets, ByteBuffer buf) {
        if (octets == null) {
            octets = new short[0];
        }
        int pos = buf.position();
        for (int i = octets.length - 1; i >= 0; i--) {
            pos--;
            buf.put(pos, (byte) octets[i]);
        }
        buf.position(buf.position() - octets.length);
        int headerLength = DerUtils.encodeIdAndLength(DerId.TagClass.UNIVERSAL, DerId.EncodingType.PRIMITIVE,
                ASN1_OCTET_STRING_TAG_NUM, octets.length, buf);
        return headerLength + octets.length;
    }
324795
public static String encodeBytes(byte[] source, int off, int len) {
        return encodeBytes(source, off, len, NO_OPTIONS);
    }
686148
@Override
    protected final void encode(final ChannelHandlerContext ctx, final JNRPEResponse msg, final ByteBuf out) {
        out.writeBytes(msg.toByteArray());
    }
77160
private static String getBase64EncodedString(String str) {
    ByteBuf byteBuf = null;
    ByteBuf encodedByteBuf = null;
    try {
      byteBuf = Unpooled.wrappedBuffer(str.getBytes(StandardCharsets.UTF_8));
      encodedByteBuf = Base64.encode(byteBuf);
      return encodedByteBuf.toString(StandardCharsets.UTF_8);
    } finally {
      // The release is called to suppress the memory leak error messages raised by netty.
      if (byteBuf != null) {
        byteBuf.release();
        if (encodedByteBuf != null) {
          encodedByteBuf.release();
        }
      }
    }
  }
539081
public static String encodeBase64(final byte[] data, final boolean chunked) {
        if (data != null && data.length > 0) {
            if (chunked) {
                return BASE64_CHUNKED_ENCODER.encodeToString(data).trim();
            }
            return BASE64_UNCHUNKED_ENCODER.encodeToString(data).trim();
        }
        return StringUtils.EMPTY;
    }
244834
public static String encodeStringsAsBase64Parameter(List<String> strings) {

        JSONArray array = new JSONArray();
        for (String string : strings) {
            array.put(string);
        }
        byte[] bytes;
        try {
            // use obfuscateBytes here to to make the output look more random
            bytes = obfuscateBytes(array.toString().getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            // should never happen
            e.printStackTrace();
            throw new RuntimeException(e);
        }
        String result = Base64.encodeBase64String(bytes);
        result = StringUtils.replaceChars(result, BASE64_EXTRA, BASE64_EXTRA_REPLACEMENTS);
        return result;
    }