Creates a UTF-8 encoded hash using the hash function

@param input string to encode
@param function hash function to use
@return the hash code
179345
public static HashCode newHash(String input, HashFunction function) {
        return function.hashString(input, Charsets.UTF_8);
    }
974355
function version_1(input){
	var hash = 2166136261; //offset: 2166136261 = 0x811c9dc5 

	for(var i=0; i< input.length; i++){
		hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
		hash ^= input.charCodeAt(i);
	}

	return hash >>> 0;
}
140984
public static String HTMLEntityEncode(String input) {
        String next = scriptPattern.matcher(input).replaceAll("&#x73;cript");

        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < next.length(); ++i) {
            char ch = next.charAt(i);

            if (ch == '<') {
                sb.append("&lt;");
            } else if (ch == '>') {
                sb.append("&gt;");
            } else {
                sb.append(ch);
            }
        }

        return sb.toString();
    }
336554
private static String bytesToUTF8(final byte[] body) {
    final String encoded = new String(body, Charset.forName("UTF-8"));
    return encoded;
  }
668634
public static String hashString(String input, int length) {
		MessageDigest md;
		try {
			md = MessageDigest.getInstance("SHA");
		} catch (NoSuchAlgorithmException e) {
			throw new IllegalArgumentException("The SHA Algorithm could not be found", e);
		}
		byte[] bytes = input.getBytes();
		md.update(bytes);
		String hashed =  convertToHex(md.digest());
		hashed = reduceHash(hashed, length);
		return hashed;
	}
256228
function fromBytes(input){
    var output = '';
    var len = input.length;
    var i = 0;
    var b1;
    var b2;

    while (i < len)
    {
      b1 = input[i++] || 0;
      b2 = input[i++] || 0;
      output += String.fromCharCode((b2 << 8) | b1);
    }
    return output;
  }
1094819
public static byte[] sha1(byte[] input) {
        MessageDigest messageDigest = sha1Digest.get();

        if (messageDigest == null) {
            try {
                messageDigest = MessageDigest.getInstance("SHA1");
                sha1Digest.set(messageDigest);
            } catch (NoSuchAlgorithmException e) {
                throw new UaRuntimeException(StatusCodes.Bad_InternalError, e);
            }
        }

        return messageDigest.digest(input);
    }
179015
public static String urlEncode(String input) {
        try {
            return URLEncoder.encode(input, "UTF-8");
        } catch (UnsupportedEncodingException ex) {
            throw new AssertionError("UTF-8 not supported", ex);
        }
    }
60047
@Override
    public String hash(String input, Hash hashType) {
        Preconditions.checkNotNull(input);
        Preconditions.checkNotNull(hashType);
        try {
            MessageDigest m = MessageDigest.getInstance(hashType.toString());
            byte[] out = m.digest(input.getBytes(Charsets.UTF_8));
            return encodeBase64(out);
        } catch (NoSuchAlgorithmException e) {
            throw new IllegalArgumentException(e);
        }
    }
1025209
function customBase64Hash(str, hashFunction) {
  const result = hashFunction(str).toString(encBase64);
  return customBase64(result);
}
802969
function(s, formatFunction) {
		var b;
		var a = {};
		var m;

		if (typeof (s) === 'string') {

			formatFunction = formatFunction || decodeURIComponent;

			m = s.replace(/^[\#\?]/, '').match(/([^=\/\&]+)=([^\&]+)/g);
			if (m) {
				for (var i = 0; i < m.length; i++) {
					b = m[i].match(/([^=]+)=(.*)/);
					a[b[1]] = formatFunction(b[2]);
				}
			}

			return a;
		}
		else {

			formatFunction = formatFunction || encodeURIComponent;

			var o = s;

			a = [];

			for (var x in o) {if (o.hasOwnProperty(x)) {
				if (o.hasOwnProperty(x)) {
					a.push([x, o[x] === '?' ? '?' : formatFunction(o[x])].join('='));
				}
			}}

			return a.join('&');
		}
	}
551316
function hashCode() {
    var args = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        args[_i - 0] = arguments[_i];
    }
    var hash = 0;
    for (var i = 0; i < args.length; ++i) {
        var str = args[i] || '';
        for (var j = 0, l = str.length; j < l; ++j) {
            var char = str.charCodeAt(j);
            hash = ((hash << 5) - hash) + char;
            hash |= 0; // Convert to 32bit integer
        }
    }
    return hash;
}
781395
function hashThisString(string) {
    var hash = 0;
    if (string.length === 0) { return hash; }
    for (var i = 0; i < string.length; i++) {
      var char = string.charCodeAt(i);
      hash = ((hash << 5) - hash) + char;
      hash = hash & hash; // Convert to 32bit integer
    }
    return hash;
  }
273129
function hashUUID(hashFn, options, buffer, offset) {
	var i, v;
	var output = buffer || new Buffer(16);
	offset = offset || 0;
	options = options || {};

	if (!options.data) {
		for (i=0; i<16; i++) {
			output[i] = 0;
		}
		return buffer || unparse(output);
	}

	if (typeof options.ns === 'string') {
		options.ns = parse(options.ns, new Buffer(16));
	}

	var hasher = crypto.createHash(hashFn);
	hasher.update(options.ns || '');
	hasher.update(options.data || '');

	switch (hashFn) {
		case 'md5': v = 0x30; break;
		case 'sha1': v = 0x50; break;
	}
	output.write(hasher.digest('binary'), offset, 16, 'binary');
	output[offset + 8] = output[offset + 8] & 0x3f | 0x80; // set variant
	output[offset + 6] = output[offset + 6] & 0x0f | v; // set version

	return buffer || unparse(output);
}
243960
function (str, algorithm, encoding) {
        try {
            return crypto
                .createHash(algorithm || 'md5')
                .update(str, 'utf8')
                .digest(encoding || 'hex')
        } catch (err) {
            return err
        }
    }
816641
function sha1(str) {
	      var utf8 = utf8Encode(str);
	      var words32 = stringToWords32(utf8);
	      var len = utf8.length * 8;
	      var w = new Array(80);
	      var _a = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4];
	      words32[len >> 5] |= 0x80 << (24 - len % 32);
	      words32[((len + 64 >> 9) << 4) + 15] = len;
	      for (var i = 0; i < words32.length; i += 16) {
	          var _b = [a, b, c, d, e], h0 = _b[0], h1 = _b[1], h2 = _b[2], h3 = _b[3], h4 = _b[4];
	          for (var j = 0; j < 80; j++) {
	              if (j < 16) {
	                  w[j] = words32[i + j];
	              }
	              else {
	                  w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
	              }
	              var _c = fk(j, b, c, d), f = _c[0], k = _c[1];
	              var temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
	              _d = [d, c, rol32(b, 30), a, temp], e = _d[0], d = _d[1], c = _d[2], b = _d[3], a = _d[4];
	          }
	          _e = [add32(a, h0), add32(b, h1), add32(c, h2), add32(d, h3), add32(e, h4)], a = _e[0], b = _e[1], c = _e[2], d = _e[3], e = _e[4];
	      }
	      var sha1 = words32ToString([a, b, c, d, e]);
	      var hex = '';
	      for (var i = 0; i < sha1.length; i++) {
	          var b_1 = sha1.charCodeAt(i);
	          hex += (b_1 >>> 4 & 0x0f).toString(16) + (b_1 & 0x0f).toString(16);
	      }
	      return hex.toLowerCase();
	      var _d, _e;
	  }
1078471
private String createChecksum(String input) {
        StringBuilder sb = new StringBuilder();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(input.getBytes());
            byte[] digest = md.digest();
            for (byte b : digest) {
                sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
            }
        } catch (Exception ignored) {
        }
        return sb.toString();
    }