Input must be 64-char hex string
11296
def privtopub(priv,outcompressed=True):
    '''
    
    '''

    x, y = ecmultiply(Gx,Gy,int(priv,16))
    x = dechex(x,32)
    y = dechex(y,32)
    o = '04' + x + y
    if outcompressed:
        return compress(o)
    else:
        return o
650900
def long2str(l):
    """"""
    if type(l) not in (types.IntType, types.LongType):
        raise ValueError('the input must be an integer')

    if l < 0:
        raise ValueError('the input must be greater than 0')
    s = ''
    while l:
        s = s + chr(l & 255)
        l >>= 8

    return s
902272
def serialize_input(input, signature_script_hex=''):
    
    if not (isinstance(input, dict) and 'transaction_hash' in input \
            and 'output_index' in input):
        raise Exception('Required parameters: transaction_hash, output_index')

    if is_hex(str(input['transaction_hash'])) and len(str(input['transaction_hash'])) != 64:
        raise Exception("Transaction hash '%s' must be 32 bytes" % input['transaction_hash'])

    elif not is_hex(str(input['transaction_hash'])) and len(str(input['transaction_hash'])) != 32:
        raise Exception("Transaction hash '%s' must be 32 bytes" % hexlify(input['transaction_hash']))

    if not 'sequence' in input:
        input['sequence'] = UINT_MAX

    return ''.join([
        flip_endian(input['transaction_hash']),
        hexlify(struct.pack('<I', input['output_index'])),
        hexlify(variable_length_int(len(signature_script_hex)/2)),
        signature_script_hex,
        hexlify(struct.pack('<I', input['sequence']))
    ])
1342588
function (params, funAbi, callback) {
    var data = ''
    var dataHex = ''
    var funArgs
    if (params.indexOf('raw:0x') === 0) {
      // in that case we consider that the input is already encoded and *does not* contain the method signature
      dataHex = params.replace('raw:0x', '')
      data = Buffer.from(dataHex, 'hex')
    } else {
      try {
        params = params.replace(/(^|,\s+|,)(\d+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted number by quoted number
        params = params.replace(/(^|,\s+|,)(0[xX][0-9a-fA-F]+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted hex string by quoted hex string
        funArgs = JSON.parse('[' + params + ']')
      } catch (e) {
        callback('Error encoding arguments: ' + e)
        return
      }
      if (funArgs.length > 0) {
        try {
          data = helper.encodeParams(funAbi, funArgs)
          dataHex = data.toString('hex')
        } catch (e) {
          callback('Error encoding arguments: ' + e)
          return
        }
      }
      if (data.slice(0, 9) === 'undefined') {
        dataHex = data.slice(9)
      }
      if (data.slice(0, 2) === '0x') {
        dataHex = data.slice(2)
      }
    }
    callback(null, { data: data, dataHex: dataHex, funArgs: funArgs })
  }
56598
function hextob64nl(s) {
    var b64 = hextob64(s);
    var b64nl = b64.replace(/(.{64})/g, "$1\r\n");
    b64nl = b64nl.replace(/\r\n$/, '');
    return b64nl;
}
834126
public static long hexDigitsToLong(String hexDigits) throws SQLParser.Exception {

        // BigInteger.longValue() will truncate to the lowest 64 bits,
        // so we need to explicitly check if there's too many digits.
        if (hexDigits.length() > 16) {
            throw new SQLParser.Exception("Too many hexadecimal digits for BIGINT value");
        }

        if (hexDigits.length() == 0) {
            throw new SQLParser.Exception("Zero hexadecimal digits is invalid for BIGINT value");
        }

        // The method
        //   Long.parseLong(<digits>, <radix>);
        // Doesn't quite do what we want---it expects a '-' to
        // indicate negative values, and doesn't want the sign bit set
        // in the hex digits.
        //
        // Once we support Java 1.8, we can use Long.parseUnsignedLong(<digits>, 16)
        // instead.

        long val = new BigInteger(hexDigits, 16).longValue();
        return val;
    }
256183
def validate_hex(value):
    """"""
    try:
        binascii.unhexlify(value)
    except Exception:
        raise vol.Invalid(
            '{} is not of hex format'.format(value))
    return value
602803
function validHex(t) {
	for (var i = 0; i < t.length; i++) {
		var c = t.charAt(i);
		if (!((c >= 'a' && c <= 'f') || (c >= '0' && c <= '9'))) return false;
	}
	return true;
}
188706
function fromUtf8(stringValue) {
  const str = new Buffer(stringValue, 'utf8');

  return `0x${padToEven(str.toString('hex')).replace(/^0+|0+$/g, '')}`;
}
225248
function token(input) {
  let token;
  
  if (typeof input === "string") {
    token = input;
  } else if (Buffer.isBuffer(input)) {
    token = input.toString("hex");
  }

  token = token.replace(/[^0-9a-f]/gi, "");

  if (token.length === 0) {
    throw new Error("Token has invalid length");
  }

  return token;
}
265432
public static final void hexToBytes(String s, byte[] out, int off)
            throws NumberFormatException, IndexOutOfBoundsException {

        int slen = s.length();
        if ((slen % 2) != 0) {
            s = '0' + s;
        }

        if (out.length < off + slen / 2) {
            throw new IndexOutOfBoundsException(
                    "Output buffer too small for input (" + out.length + '<'
                            + off + slen / 2 + ')');
        }

        // Safe to assume the string is even length
        byte b1, b2;
        for (int i = 0; i < slen; i += 2) {
            b1 = (byte) Character.digit(s.charAt(i), 16);
            b2 = (byte) Character.digit(s.charAt(i + 1), 16);
            if ((b1 < 0) || (b2 < 0)) {
                throw new NumberFormatException();
            }
            out[off + i / 2] = (byte) (b1 << 4 | b2);
        }
    }
551359
def str2long(s):
    """"""
    if type(s) not in (types.StringType, types.UnicodeType):
        raise ValueError('the input must be a string')

    l = 0
    for i in s:
        l <<= 8
        l |= ord(i)

    return l
1249845
function b64utob64(s) {
    if (s.length % 4 == 2) s = s + "==";
    else if (s.length % 4 == 3) s = s + "=";
    s = s.replace(/-/g, "+");
    s = s.replace(/_/g, "/");
    return s;
}
1089117
def hex2rgb(hexval: str, allow_short: bool = False) -> RGB:
    
    if not hexval:
        raise ValueError(
            'Expecting hex string (#RGB, #RRGGBB), got nothing: {!r}'.format(
                hexval
            )
        )
    try:
        hexval = hexval.strip().lstrip('#')
    except AttributeError:
        raise ValueError(
            'Expecting hex string (#RGB, #RRGGBB), got: ({}) {!r}'.format(
                type(hexval).__name__,
                hexval
            )
        )
    if allow_short:
        hexval = fix_hex(hexval)
    if not len(hexval) == 6:
        raise ValueError(
            'Not a length 3 or 6 hex string (#RGB, #RRGGBB), got: {}'.format(
                hexval
            )
        )
    try:
        val = tuple(
            int(''.join(hexval[i:i + 2]), 16)
            for i in range(0, len(hexval), 2)
        )
    except ValueError:
        # Bad hex string.
        raise ValueError('Invalid hex value: {}'.format(hexval))
    # Only needed to satisft typing. `return val` would work fine.
    r, g, b = val
    return r, g, b
1096319
def u64_to_hex16le(val):
    """"""
    return ''.join("%02x" % (x & 0xFF) for x in (
        val,
        val >> 8,
        val >> 16,
        val >> 24,
        val >> 32,
        val >> 40,
        val >> 48,
        val >> 56,
    ))
480667
function decodeBase64(sEncoded) {

    // Input must be dividable with 4.
    if (!sEncoded || (sEncoded.length % 4) > 0) { return sEncoded; }
    else if (typeof (atob) != 'undefined') { return atob(sEncoded); }

    var nBits, i, sDecoded = '';
    var base64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

    sEncoded = sEncoded.replace(/\W|=/g, '');
    for (i = 0; i < sEncoded.length; i += 4) {
        nBits =
            (base64.indexOf(sEncoded.charAt(i)) & 0xff) << 18 |
            (base64.indexOf(sEncoded.charAt(i + 1)) & 0xff) << 12 |
            (base64.indexOf(sEncoded.charAt(i + 2)) & 0xff) << 6 |
             base64.indexOf(sEncoded.charAt(i + 3)) & 0xff;
        sDecoded += String.fromCharCode(
            (nBits & 0xff0000) >> 16, (nBits & 0xff00) >> 8, nBits & 0xff);
    }
    return sDecoded.substring(0, sDecoded.length -
        ((sEncoded.charCodeAt(i - 2) == 61) ? 2 :
        (sEncoded.charCodeAt(i - 1) == 61 ? 1 : 0)));

}
792562
public static void convertToHex(long value, Appendable out) throws IOException {
		convertToHex((int)(value >>> 32), out);
		convertToHex((int)value, out);
	}