改进的32位FNV算法1

@param data 字符串
@return hash结果
969919
public static int fnvHash(String data) {
		final int p = 16777619;
		int hash = (int) 2166136261L;
		for (int i = 0; i < data.length(); i++) {
			hash = (hash ^ data.charAt(i)) * p;
		}
		hash += hash << 13;
		hash ^= hash >> 7;
		hash += hash << 3;
		hash ^= hash >> 17;
		hash += hash << 5;
		return hash;
	}
735647
public void append(byte data) {
        // 当数组长度等于当前数据大小时进行扩展
        if (0 >= (this.datas.length - size)) {
            // 如果扩展后的数组大于当前数组，那么先把当前数组长度增加，一次扩展256
            byte[] newData = new byte[256 + size];
            System.arraycopy(this.datas, 0, newData, 0, size);
            this.datas = newData;
        }
        this.datas[size] = data;
        this.size += 1;
        modCount++;
    }
98576
public static byte[] sha384Hash(String data, Charset charset) throws NoSuchAlgorithmException {
		return sha384Hash(data.getBytes(charset));
	}
887313
public long hash64( final byte[] data, int length, int seed) {
		final long m = 0xc6a4a7935bd1e995L;
		final int r = 47;

		long h = (seed&0xffffffffl)^(length*m);

		int length8 = length/8;

		for (int i=0; i<length8; i++) {
			final int i8 = i*8;
			long k =  ((long)data[i8+0]&0xff)      +(((long)data[i8+1]&0xff)<<8)
					+(((long)data[i8+2]&0xff)<<16) +(((long)data[i8+3]&0xff)<<24)
					+(((long)data[i8+4]&0xff)<<32) +(((long)data[i8+5]&0xff)<<40)
					+(((long)data[i8+6]&0xff)<<48) +(((long)data[i8+7]&0xff)<<56);

			k *= m;
			k ^= k >>> r;
					k *= m;

					h ^= k;
					h *= m; 
		}

		switch (length%8) {
		case 7: h ^= (long)(data[(length&~7)+6]&0xff) << 48;
		case 6: h ^= (long)(data[(length&~7)+5]&0xff) << 40;
		case 5: h ^= (long)(data[(length&~7)+4]&0xff) << 32;
		case 4: h ^= (long)(data[(length&~7)+3]&0xff) << 24;
		case 3: h ^= (long)(data[(length&~7)+2]&0xff) << 16;
		case 2: h ^= (long)(data[(length&~7)+1]&0xff) << 8;
		case 1: h ^= (long)(data[length&~7]&0xff);
		h *= m;
		};

		h ^= h >>> r;
		h *= m;
		h ^= h >>> r;

		return h;
	}
5682
def fnv(data, hval_init, fnv_prime, fnv_size):
    
    assert isinstance(data, bytes)

    hval = hval_init
    for byte in data:
        hval = (hval * fnv_prime) % fnv_size
        hval = hval ^ _get_byte(byte)
    return hval
435385
protected String hashByteArray(byte[] data) {
        if (mCRC32 != null) {
            return hashCRC32(data);
        } else if (mHashAlgorithm != null) {
            return messageDigest(data);
        } else {
            // Default.
            return hashCRC32(data);
        }
    }
818011
def murmur3_x86_32(data: Union[bytes, bytearray], seed: int = 0) -> int:
      # noqa
    c1 = 0xcc9e2d51
    c2 = 0x1b873593

    length = len(data)
    h1 = seed
    rounded_end = (length & 0xfffffffc)  # round down to 4 byte block
    for i in range(0, rounded_end, 4):
        # little endian load order
        # RNC: removed ord() calls
        k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) | \
             ((data[i + 2] & 0xff) << 16) | (data[i + 3] << 24)
        k1 *= c1
        k1 = (k1 << 15) | ((k1 & 0xffffffff) >> 17)  # ROTL32(k1, 15)
        k1 *= c2

        h1 ^= k1
        h1 = (h1 << 13) | ((h1 & 0xffffffff) >> 19)  # ROTL32(h1, 13)
        h1 = h1 * 5 + 0xe6546b64

    # tail
    k1 = 0

    val = length & 0x03
    if val == 3:
        k1 = (data[rounded_end + 2] & 0xff) << 16
    # fallthrough
    if val in (2, 3):
        k1 |= (data[rounded_end + 1] & 0xff) << 8
    # fallthrough
    if val in (1, 2, 3):
        k1 |= data[rounded_end] & 0xff
        k1 *= c1
        k1 = (k1 << 15) | ((k1 & 0xffffffff) >> 17)  # ROTL32(k1, 15)
        k1 *= c2
        h1 ^= k1

    # finalization
    h1 ^= length

    # fmix(h1)
    h1 ^= ((h1 & 0xffffffff) >> 16)
    h1 *= 0x85ebca6b
    h1 ^= ((h1 & 0xffffffff) >> 13)
    h1 *= 0xc2b2ae35
    h1 ^= ((h1 & 0xffffffff) >> 16)

    return h1 & 0xffffffff
644851
public final long hash(byte[] data, int c, int d) {
        return SipHasher.hash(
            c, d,
            this.v0,
            this.v1,
            this.v2,
            this.v3,
            data
        );
    }
723749
function getNumericHash(data) {
	var hash = crypto.createHash('md5'),
		numeric = 0,
		buf;
	hash.update(data + '-Phonetic');
	buf = hash.digest();
	for (var i = 0; i <= 12; i += 4)
		numeric += buf.readUInt32LE(i);
	return numeric;
}
536982
function fnv(seed, data) {
		var h = new FNV()
		h.update(seed)
		h.update(data)
		return h.value() >>> 0
	}
1019500
public static String hmacSHA1(String data, String key) {
		StringBuilder sb = new StringBuilder();
		try {
			byte[] keyBytes = key.getBytes();
			SecretKeySpec signingKey = new SecretKeySpec(keyBytes, "HmacSHA1");
			Mac mac = Mac.getInstance("HmacSHA1");
			mac.init(signingKey);
			byte[] rawHmac = mac.doFinal(data.getBytes());
			for (byte b : rawHmac) {
				sb.append(byteToHexString(b));
			}
		}
		catch (Exception e) {
			throw new RuntimeException("获取HmacSHA1签名失败[" + e.getMessage() + "]!", e);
		}
		return sb.toString();
	}
570602
function hash256(data) {
  const out = Buffer.allocUnsafe(32);
  ctx.init();
  ctx.update(data);
  ctx._finish(out);
  ctx.init();
  ctx.update(out);
  ctx._finish(out);
  return out;
}
677854
public static InterleavedF32 nv21ToInterleaved( byte[] data , int width , int height ,
															   InterleavedF32 output ) {
		if( output == null ) {
			output = new InterleavedF32(width,height,3);
		} else {
			output.reshape(width, height, 3);
		}

		if(BoofConcurrency.USE_CONCURRENT ) {
			ImplConvertNV21_MT.nv21ToInterleaved_F32(data, output);
		} else {
			ImplConvertNV21.nv21ToInterleaved_F32(data, output);
		}

		return output;
	}
170428
public static long[] hashToLongs(final byte[] data, final long seed) {
    if ((data == null) || (data.length == 0)) {
      return null;
    }
    return hash(data, seed);
  }
136377
public static byte[] convert(int data) {
        long len = Integer.toUnsignedLong(data);
        byte[] b = new byte[Datagram.LEN_LIMIT];
        for (int i = 0; i < b.length; i++) {
            b[i] = (byte) (len >> ((b.length - i - 1) * 8));
        }
        return b;
    }
497814
public byte[] hash(byte[] data) throws SdkClientException {
        try {
            MessageDigest md =  getMessageDigestInstance();
            md.update(data);
            return md.digest();
        } catch (Exception e) {
            throw new SdkClientException(
                    "Unable to compute hash while signing request: "
                            + e.getMessage(), e);
        }
    }
1356335
public static HashMap<String, String> getTavAndAmp(HashMap data) {

        HashMap<String, String> results = new HashMap<String, String>();
        HashMap<Integer, MonthlyAvg> tyear = new HashMap<Integer, MonthlyAvg>();
        MonthlyAvg tmonth;
        MonthlyAvg tavAllYears;
        ArrayList<String> tampAllYears;
        String tav;
        String tamp;
        ArrayList<HashMap<String, String>> dailyArr = getDailyData(data);

        // Load daily data
        for (int i = 0; i < dailyArr.size(); i++) {

            String date;
            int year;
            int month;
            String tmax;
            String tmin;
            String tavgDaily;

            HashMap<String, String> dailyData = dailyArr.get(i);
            date = getValueOr(dailyData, "w_date", "").trim();
            if (date.equals("")) {
                LOG.warn("There is daily data do not having a valid date");
                continue;
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(convertFromAgmipDateString(date));
                year = cal.get(Calendar.YEAR);
                month = cal.get(Calendar.MONTH);
                tmonth = tyear.get(year);
                if (tmonth == null) {
                    tmonth = new MonthlyAvg();
                    tyear.put(year, tmonth);
                }
            }

            tmax = getValueOr(dailyData, "tmax", "").trim();
            tmin = getValueOr(dailyData, "tmin", "").trim();
            tavgDaily = average(tmax, tmin);
            if (tavgDaily != null) {
                tmonth.add(month, tavgDaily);
            }
        }

        // Calculate daily data
        tavAllYears = new MonthlyAvg();
        tampAllYears = new ArrayList();
        for (Iterator<Integer> it = tyear.keySet().iterator(); it.hasNext();) {
            int year = it.next();
            tmonth = tyear.get(year);
            String[] tavgs = tmonth.getAllAvg();
            // TAV
            for (int month = 0; month < tavgs.length; month++) {
                tavAllYears.add(month, tavgs[month]);
            }
            // TAMP
            String tampt = substract(max(tavgs), min(tavgs));
            if (tampt != null) {
                tampAllYears.add(tampt);
            }

        }
        tav = average(2, removeNull(tavAllYears.getAllAvg()));
        tamp = average(2, tampAllYears.toArray(new String[0]));

        if (tav != null) {
            results.put("tav", tav);
        }
        if (tamp != null) {
            results.put("tamp", tamp);
        }
        return results;
    }