create a base64 url-safe hash (escape some chars)
352532
function base64urlsafe(hash){
    // replace some chars
    hash = hash.replace(/\//g, '_').replace(/\+/g, '-').replace(/=/g, '');

    return hash;
}
1010569
def alphanumeric_hash(s: str, size=5):
  """"""
  import hashlib
  import base64
  hash_object = hashlib.md5(s.encode('ascii'))
  s = base64.b32encode(hash_object.digest())
  result = s[:size].decode('ascii').lower()
  return result
406346
def generate_http_basic_token(username, password):
    
    token = base64.b64encode('{}:{}'.format(username, password).encode('utf-8')).decode('utf-8')
    return token
677050
private String escapeToLower(String url) {
        String encodedUrl = StringUtils.urlEncode(url, UNSAFE_URL_CHARS_PATTERN, Charset.forName("UTF-8"));
        return encodedUrl;
    }
1035338
function(str, _url) {
    str = str.replace(/\s|=/g,'');
    var out = [], i, bits=0, c = sjcl.codec.base64._chars, ta=0, x;
    if (_url) {
      c = c.substr(0,62) + '-_';
    }
    for (i=0; i<str.length; i++) {
      x = c.indexOf(str.charAt(i));
      if (x < 0) {
        throw new sjcl.exception.invalid("this isn't base64!");
      }
      if (bits > 26) {
        bits -= 26;
        out.push(ta ^ x>>>bits);
        ta  = x << (32-bits);
      } else {
        bits += 6;
        ta ^= x << (32-bits);
      }
    }
    if (bits&56) {
      out.push(sjcl.bitArray.partial(bits&56, ta, 1));
    }
    return out;
  }
91974
function toBase64URL(data) {
    if (typeof data === 'string') {
        data = new Buffer(data);
    }

    return data.toString('base64')
        .replace(/=+/g, '')     // remove '='s
        .replace(/\+/g, '-')    // '+' → '-'
        .replace(/\//g, '_');   // '/' → '_'
}
164325
function base64url_decode(input) {
    return Base64.decode(input.replace(/-/g, '+').replace(/_/g, '/'));
}
1177805
def pack_urlsafe_base64digest(bin)
      str = pack_base64digest(bin)
      str.tr!('+/'.freeze, '-_'.freeze)
      str.tr!('='.freeze, ''.freeze)
      str
    end
59656
def __FinalUrlValue(self, value, field):
        """"""
        if isinstance(field, messages.BytesField) and value is not None:
            return base64.urlsafe_b64encode(value)
        elif isinstance(value, six.text_type):
            return value.encode('utf8')
        elif isinstance(value, six.binary_type):
            return value.decode('utf8')
        elif isinstance(value, datetime.datetime):
            return value.isoformat()
        return value
225612
def base64url_decode(msg):
    
    rem = len(msg) % 4
    if rem:
        msg += b'=' * (4 - rem)

    return base64.urlsafe_b64decode(msg)
1050559
def base64_user_pass(self):
        
        if self._username is None or self._password is None:
            return None

        hash_ = base64.urlsafe_b64encode(bytes_("{username}:{password}".format(
            username=self._username,
            password=self._password
        )))
        return "Basic {0}".format(unicode_(hash_))
1151477
def md5hash(self):
        """"""
        digest = hashlib.md5(self.content).digest()
        return b64_string(digest)
790951
def _dhash(self, params):
        """"""
        m = hashlib.new('md5')
        m.update(self.hash.encode('utf-8'))
        for key in sorted(params.keys()):
            h_string = ('%s-%s' % (key, params[key])).encode('utf-8')
            m.update(h_string)
        return m.hexdigest()
690153
def make_hash(str)

      str = str.split('&')
      hash = {}

      str.each do |s|
        opt = s.split('=')
        hash[opt[0]] = URI.unescape(opt[1].to_s.gsub('+', ' '))
      end

      hash

    end
1276417
def chunk(url):
    
    chunks = lambda l, n: [l[x: x+n] for x in xrange(0, len(l), n)]
    url_64 = base64.urlsafe_b64encode(url)
    return chunks(url_64, 255)
1138125
function hash (str) {
  return crypto
    .createHash('sha1')
    .update(str, 'ascii')
    .digest('base64')
    .replace(PLUS_GLOBAL_REGEXP, '-')
    .replace(SLASH_GLOBAL_REGEXP, '_')
    .replace(EQUAL_GLOBAL_REGEXP, '')
}
1183856
private String base64(String value)
    {
        StringBuffer cb = new StringBuffer();

        int i = 0;
        for (i = 0; i + 2 < value.length(); i += 3) {
            long chunk = (int) value.charAt(i);
            chunk = (chunk << 8) + (int) value.charAt(i + 1);
            chunk = (chunk << 8) + (int) value.charAt(i + 2);

            cb.append(encode(chunk >> 18));
            cb.append(encode(chunk >> 12));
            cb.append(encode(chunk >> 6));
            cb.append(encode(chunk));
        }

        if (i + 1 < value.length()) {
            long chunk = (int) value.charAt(i);
            chunk = (chunk << 8) + (int) value.charAt(i + 1);
            chunk <<= 8;

            cb.append(encode(chunk >> 18));
            cb.append(encode(chunk >> 12));
            cb.append(encode(chunk >> 6));
            cb.append('=');
        }
        else if (i < value.length()) {
            long chunk = (int) value.charAt(i);
            chunk <<= 16;

            cb.append(encode(chunk >> 18));
            cb.append(encode(chunk >> 12));
            cb.append('=');
            cb.append('=');
        }

        return cb.toString();
    }