Returned the encoding as an uncloned byte array. Callers must
guarantee that they neither modify it not expose it to untrusted
code.
427862
public byte[] getEncodedInternal() throws IOException {
        if (encoded == null) {
            DerOutputStream     out = new DerOutputStream();
            DerOutputStream     tmp = new DerOutputStream();
            for (int i = 0; i < names.length; i++) {
                names[i].encode(tmp);
            }
            out.write(DerValue.tag_Sequence, tmp);
            encoded = out.toByteArray();
        }
        return encoded;
    }
866152
private static byte[] deobfuscateBytes(byte[] source) {

        byte[] result = new byte[source.length - 1];
        System.arraycopy(source, 1, result, 0, source.length - 1);
        for (int i = 0; i < result.length; i++) {
            result[i] = (byte)(0xFF & (result[i] ^ source[0]));
        }
        return result;
    }
717694
def _ensure_decoded(s):
    
    if isinstance(s, np.bytes_):
        s = s.decode('UTF-8')
    return s
808241
public byte[] encode() throws IllegalStateException {
		prepareForEncoding();

		// make sure we have everything necessary to encode a proper message
		validateAttributePresentity();

		final char dataLength = getDataLength();

		byte binMsg[] = new byte[HEADER_LENGTH + dataLength];
		int offset = 0;

		// STUN Message Type
		binMsg[offset++] = (byte) (getMessageType() >> 8);
		binMsg[offset++] = (byte) (getMessageType() & 0xFF);

		// Message Length
		final int messageLengthOffset = offset;

		offset += 2;

		byte tranID[] = getTransactionId();

		if (tranID.length == 12) {
			System.arraycopy(MAGIC_COOKIE, 0, binMsg, offset, 4);
			offset += 4;
			System.arraycopy(tranID, 0, binMsg, offset, TRANSACTION_ID_LENGTH);
			offset += TRANSACTION_ID_LENGTH;
		} else {
			/* RFC3489 behavior */
			System.arraycopy(tranID, 0, binMsg, offset, RFC3489_TRANSACTION_ID_LENGTH);
			offset += RFC3489_TRANSACTION_ID_LENGTH;
		}

		Vector<Map.Entry<Character, StunAttribute>> v = new Vector<Map.Entry<Character, StunAttribute>>();
		Iterator<Map.Entry<Character, StunAttribute>> iter = null;
		char dataLengthForContentDependentAttribute = 0;

		synchronized (attributes) {
			v.addAll(attributes.entrySet());
		}

		iter = v.iterator();

		while (iter.hasNext()) {
			StunAttribute attribute = iter.next().getValue();
			int attributeLength = attribute.getDataLength() + StunAttribute.HEADER_LENGTH;

			// take attribute padding into account:
			attributeLength += (4 - attributeLength % 4) % 4;
			dataLengthForContentDependentAttribute += attributeLength;

			// special handling for message integrity and fingerprint values
			byte[] binAtt;

			if (attribute instanceof ContextDependentAttribute) {
				/*
				 * The "Message Length" seen by a ContextDependentAttribute is
				 * up to and including the very Attribute but without any other
				 * Attribute instances after it.
				 */
				binMsg[messageLengthOffset] = (byte) (dataLengthForContentDependentAttribute >> 8);
				binMsg[messageLengthOffset + 1] = (byte) (dataLengthForContentDependentAttribute & 0xFF);
				binAtt = ((ContextDependentAttribute) attribute).encode(binMsg, 0, offset);
			} else {
				binAtt = attribute.encode();
			}

			System.arraycopy(binAtt, 0, binMsg, offset, binAtt.length);
			/*
			 * Offset by attributeLength and not by binAtt.length because
			 * attributeLength takes the attribute padding into account and
			 * binAtt.length does not.
			 */
			offset += attributeLength;
		}

		// Message Length
		binMsg[messageLengthOffset] = (byte) (dataLength >> 8);
		binMsg[messageLengthOffset + 1] = (byte) (dataLength & 0xFF);

		return binMsg;
	}
418909
public static byte[] asBytesUnchecked(final Object value) {
    try {
      return OBJECT_MAPPER.writeValueAsBytes(value);
    } catch (JsonProcessingException e) {
      throw new RuntimeException(e);
    }
  }
888260
public static byte[] getUnicodeByteArray(String str) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream(baos);
		try {
			for (int i = 0; i < str.length(); i++) {
				dos.writeChar((int) str.charAt(i));
			}
		} catch (Exception e) {
		}

		return baos.toByteArray();
	}
723622
static public byte[] decode(String encoded) {
		if (encoded == null)
			return null;
		int lengthData = encoded.length();
		if (lengthData % 2 != 0)
			return null;

		char[] binaryData = encoded.toCharArray();
		int lengthDecode = lengthData / 2;
		byte[] decodedData = new byte[lengthDecode];
		byte temp1, temp2;
		char tempChar;
		for (int i = 0; i < lengthDecode; i++) {
			tempChar = binaryData[i * 2];
			temp1 = (tempChar < BASELENGTH) ? hexNumberTable[tempChar] : -1;
			if (temp1 == -1)
				return null;
			tempChar = binaryData[i * 2 + 1];
			temp2 = (tempChar < BASELENGTH) ? hexNumberTable[tempChar] : -1;
			if (temp2 == -1)
				return null;
			decodedData[i] = (byte) ((temp1 << 4) | temp2);
		}
		return decodedData;
	}
1197368
private byte[] toCookedBytes()
    {
        // Allocate for a int pair per token/partition ID entry, plus a size.
        ByteBuffer buf = ByteBuffer.allocate(4 + (m_tokenCount * 8));

        buf.putInt(m_tokenCount);
        // Keep tokens and partition ids separate to aid compression.
        for (int zz = 3; zz >= 0; zz--) {
            int lastToken = Integer.MIN_VALUE;
            for (int ii = 0; ii < m_tokenCount; ii++) {
                int token = Bits.unsafe.getInt(m_tokens + (ii * 8));
                Preconditions.checkArgument(token >= lastToken);
                lastToken = token;
                token = token >>> (zz * 8);
                token = token & 0xFF;
                buf.put((byte)token);
            }
        }
        for (int ii = 0; ii < m_tokenCount; ii++) {
            buf.putInt(Bits.unsafe.getInt(m_tokens + (ii * 8) + 4));
        }

        try {
            return CompressionService.gzipBytes(buf.array());
        } catch (IOException e) {
            throw new RuntimeException("Failed to compress bytes", e);
        }
    }
474711
public byte[] encode() {
		char type = getAttributeType();
		byte binValue[] = new byte[HEADER_LENGTH + getDataLength()];

		// Type
		binValue[0] = (byte) (type >> 8);
		binValue[1] = (byte) (type & 0x00FF);

		// Length
		binValue[2] = (byte) (getDataLength() >> 8);
		binValue[3] = (byte) (getDataLength() & 0x00FF);

		return binValue;
	}
422804
public static String encodeBytes(byte[] bytes)
    {
        String ret = null;

        try
        {
            // Obfuscate the string
            if(bytes != null)
                ret = new String(Base64.encodeBase64(bytes));
        }
        catch(NoClassDefFoundError e)
        {
            ret = new String(bytes);
            System.out.println("WARNING: unable to encode: "
                +e.getClass().getName()+": "+e.getMessage());
        }

        return ret;
    }
1372262
public static byte[] decode(String s) {
		byte[] bytes;
		try {
			bytes = s.getBytes(PREFERRED_ENCODING);
		} // end try
		catch (java.io.UnsupportedEncodingException uee) {
			bytes = s.getBytes();
		} // end catch

		// Decode
		bytes = decode(bytes);

		return bytes;
	}
1199291
final byte[] decodeChecked(CharSequence chars) throws DecodingException {
    chars = padding().trimTrailingFrom(chars);
    ByteInput decodedInput = decodingStream(asCharInput(chars));
    byte[] tmp = new byte[maxDecodedSize(chars.length())];
    int index = 0;
    try {
      for (int i = decodedInput.read(); i != -1; i = decodedInput.read()) {
        tmp[index++] = (byte) i;
      }
    } catch (DecodingException badInput) {
      throw badInput;
    } catch (IOException impossible) {
      throw new AssertionError(impossible);
    }
    return extract(tmp, index);
  }
3530
function() {

    var _buffer = 0;
    var _buflen = 0;
    var _length = 0;
    var _base64 = '';

    var _this = {};

    var writeEncoded = function(b) {
      _base64 += String.fromCharCode(encode(b & 0x3f) );
    };

    var encode = function(n) {
      if (n < 0) {
        // error.
      } else if (n < 26) {
        return 0x41 + n;
      } else if (n < 52) {
        return 0x61 + (n - 26);
      } else if (n < 62) {
        return 0x30 + (n - 52);
      } else if (n == 62) {
        return 0x2b;
      } else if (n == 63) {
        return 0x2f;
      }
      throw 'n:' + n;
    };

    _this.writeByte = function(n) {

      _buffer = (_buffer << 8) | (n & 0xff);
      _buflen += 8;
      _length += 1;

      while (_buflen >= 6) {
        writeEncoded(_buffer >>> (_buflen - 6) );
        _buflen -= 6;
      }
    };

    _this.flush = function() {

      if (_buflen > 0) {
        writeEncoded(_buffer << (6 - _buflen) );
        _buffer = 0;
        _buflen = 0;
      }

      if (_length % 3 != 0) {
        // padding
        var padlen = 3 - _length % 3;
        for (var i = 0; i < padlen; i += 1) {
          _base64 += '=';
        }
      }
    };

    _this.toString = function() {
      return _base64;
    };

    return _this;
  }
1040695
public static String bytesToString(ByteBuffer b) {
    return Unpooled.wrappedBuffer(b).toString(StandardCharsets.UTF_8);
  }
183206
function() {

    var _bytes = [];

    var _this = {};

    _this.writeByte = function(b) {
      _bytes.push(b & 0xff);
    };

    _this.writeShort = function(i) {
      _this.writeByte(i);
      _this.writeByte(i >>> 8);
    };

    _this.writeBytes = function(b, off, len) {
      off = off || 0;
      len = len || b.length;
      for (var i = 0; i < len; i += 1) {
        _this.writeByte(b[i + off]);
      }
    };

    _this.writeString = function(s) {
      for (var i = 0; i < s.length; i += 1) {
        _this.writeByte(s.charCodeAt(i) );
      }
    };

    _this.toByteArray = function() {
      return _bytes;
    };

    _this.toString = function() {
      var s = '';
      s += '[';
      for (var i = 0; i < _bytes.length; i += 1) {
        if (i > 0) {
          s += ',';
        }
        s += _bytes[i];
      }
      s += ']';
      return s;
    };

    return _this;
  }
392008
public byte[] toEncodedForm() {
    if (encodedForm == null) {
      encodedForm = new byte[encodedSize()];
      ArrayUtil.writeLong(encodedForm, 0, accessSchemaId);
      encode(encodedForm, new int[] { 8, encodedForm.length });
    }
    return encodedForm;
  }
8142
public static byte[] bytes(String s) {
    try {
      return s.getBytes(ENCODING);
    } catch (UnsupportedEncodingException e) {
      log.error("UnsupportedEncodingException ", e);
      throw new RuntimeException(e);
    }
  }