當前位置: 首頁>>代碼示例>>Java>>正文


Java Adler32.getValue方法代碼示例

本文整理匯總了Java中java.util.zip.Adler32.getValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Adler32.getValue方法的具體用法?Java Adler32.getValue怎麽用?Java Adler32.getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.zip.Adler32的用法示例。


在下文中一共展示了Adler32.getValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: a

import java.util.zip.Adler32; //導入方法依賴的package包/類
private static int a(String str, int i) {
    if (TextUtils.isEmpty(str)) {
        z.b();
        return 0;
    }
    try {
        return Integer.valueOf(str).intValue();
    } catch (Exception e) {
        z.d();
        Adler32 adler32 = new Adler32();
        adler32.update(str.getBytes());
        int value = (int) adler32.getValue();
        if (value < 0) {
            value = Math.abs(value);
        }
        value += 13889152 * i;
        return value < 0 ? Math.abs(value) : value;
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:m.java

示例2: CheckCookieValue

import java.util.zip.Adler32; //導入方法依賴的package包/類
private boolean CheckCookieValue(String cookieValue) {
    try {
        Adler32 adler32 = new Adler32();        
        //adler32.update(cookieValue.substring(0, 32).getBytes());
        for (int i=0; i < 32; i++) {
            adler32.update(Integer.parseInt(cookieValue.substring(i, i+1)));                
        }        
        if (Long.parseLong(cookieValue.substring(32, cookieValue.length())) == adler32.getValue()) {            
            return true;
        } else {            
            return false;
        }
    } catch (Exception e) {
        return false;
    }
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:17,代碼來源:CookieSecurity.java

示例3: fixCheckSumHeader

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * �޸�dexͷ��CheckSum У����
 * @param dexBytes
 */
private static void fixCheckSumHeader(byte[] dexBytes) {
	Adler32 adler = new Adler32();
	adler.update(dexBytes, 12, dexBytes.length - 12);//��12���ļ�ĩβ����У����
	long value = adler.getValue();
	int va = (int) value;
	byte[] newcs = intToByte(va);
	//��λ��ǰ����λ��ǰ������
	byte[] recs = new byte[4];
	for (int i = 0; i < 4; i++) {
		recs[i] = newcs[newcs.length - 1 - i];
		System.out.println(Integer.toHexString(newcs[i]));
	}
	System.arraycopy(recs, 0, dexBytes, 8, 4);//Ч���븳ֵ��8-11��
	System.out.println(Long.toHexString(value));
	System.out.println();
}
 
開發者ID:tangsilian,項目名稱:SecurityPage,代碼行數:21,代碼來源:mymain.java

示例4: fixCheckSumHeader

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * 修改dex頭,CheckSum 校驗碼
 * @param dexBytes
 */
private static void fixCheckSumHeader(byte[] dexBytes) {
    Adler32 adler = new Adler32();
    adler.update(dexBytes, 12, dexBytes.length - 12);//從12到文件末尾計算校驗碼
    long value = adler.getValue();
    int va = (int) value;
    byte[] newcs = intToByte(va);
    //高位在前,低位在前掉個個
    byte[] recs = new byte[4];
    for (int i = 0; i < 4; i++) {
        recs[i] = newcs[newcs.length - 1 - i];
        System.out.println(Integer.toHexString(newcs[i]));
    }
    System.arraycopy(recs, 0, dexBytes, 8, 4);//效驗碼賦值(8-11)
    System.out.println(Long.toHexString(value));
    System.out.println();
}
 
開發者ID:DIY-green,項目名稱:AndroidStudyDemo,代碼行數:21,代碼來源:PackerUtil.java

示例5: hashCode

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * Get the content - dependent hashcode.
 */
public int hashCode()
{
  if (has == null)
    return type().kind().value();
  else
    {
      Adler32 adler = new Adler32();

      BufferedCdrOutput a = new BufferedCdrOutput();
      a.setOrb(orb);
      write_value(a);

      adler.update(a.buffer.toByteArray());
      adler.update(type().kind().value());

      return (int) adler.getValue() & Integer.MAX_VALUE;
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:22,代碼來源:gnuAny.java

示例6: updateChecksum

import java.util.zip.Adler32; //導入方法依賴的package包/類
public static void updateChecksum(ByteBuffer buffer, int size) {
    byte[] data = buffer.array();
    MessageDigest digest;
    try {
        digest = MessageDigest.getInstance("SHA-1");
    } catch (NoSuchAlgorithmException e) {
        throw new AssertionError();
    }

    digest.update(data, 32, size - 32);
    byte[] sha1 = digest.digest();
    System.arraycopy(sha1, 0, data, 12, sha1.length);

    Adler32 adler32 = new Adler32();
    adler32.update(data, 12, size - 12);
    int v = (int) adler32.getValue();
    buffer.position(8);
    buffer.putInt(v);
}
 
開發者ID:johnlee175,項目名稱:dex,代碼行數:20,代碼來源:DexFileWriter.java

示例7: hashCode

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * Get the content - dependent hashcode.
 */
public int hashCode()
{
  if (has == null)
    return type().kind().value();
  else
    {
      Adler32 adler = new Adler32();

      BufferedCdrOutput a = new BufferedCdrOutput();
      a.setOrb(orb);
      write_value(a);
      
      adler.update(a.buffer.toByteArray());
      adler.update(type().kind().value());
      
      return (int) adler.getValue() & Integer.MAX_VALUE;
    }
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:22,代碼來源:gnuAny.java

示例8: decompressBytes

import java.util.zip.Adler32; //導入方法依賴的package包/類
public static byte[] decompressBytes(byte[] bytesArray) throws ClientException  { 
	
	byte[] checkSumBuf = new byte[8];
	checkSumBuf[0] = bytesArray[bytesArray.length-8];
	checkSumBuf[1] = bytesArray[bytesArray.length-7];
	checkSumBuf[2] = bytesArray[bytesArray.length-6];
	checkSumBuf[3] = bytesArray[bytesArray.length-5];
	checkSumBuf[4] = bytesArray[bytesArray.length-4];
	checkSumBuf[5] = bytesArray[bytesArray.length-3];
	checkSumBuf[6] = bytesArray[bytesArray.length-2];
	checkSumBuf[7] = bytesArray[bytesArray.length-1];
	
	
	ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE / Byte.SIZE);
    buffer.put(checkSumBuf);
    buffer.flip();//need flip 
    long checkSum = buffer.getLong();
    
    Adler32 adler32 = new Adler32();
	adler32.update(bytesArray, 0, bytesArray.length-8);
	if(checkSum !=adler32.getValue())
		throw new ClientException("Data corruption detected - checksum failure. Please, try again.");
    
	return Snappy.uncompress(bytesArray, 0, bytesArray.length -8 );
}
 
開發者ID:PortfolioEffect,項目名稱:PE-HFT-Java,代碼行數:26,代碼來源:ArrayUtil.java

示例9: netSendReplay

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * NET: Send replay data<br>
 * Game modes should implement this. However, some basic codes are already implemented in NetDummyMode.
 * @param engine GameEngine
 */
protected void netSendReplay(GameEngine engine) {
	if(netIsNetRankingSendOK(engine)) {
		NetSPRecord record = new NetSPRecord();
		record.setReplayProp(owner.replayProp);
		record.stats = new Statistics(engine.statistics);
		record.gameType = netGetGoalType();

		String strData = NetUtil.compressString(record.exportString());

		Adler32 checksumObj = new Adler32();
		checksumObj.update(NetUtil.stringToBytes(strData));
		long sChecksum = checksumObj.getValue();

		netLobby.netPlayerClient.send("spsend\t" + sChecksum + "\t" + strData + "\n");
	} else {
		netReplaySendStatus = 2;
	}
}
 
開發者ID:PoochyEXE,項目名稱:nullpomino,代碼行數:24,代碼來源:NetDummyMode.java

示例10: sendMyRuleDataToServer

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * ルール data送信
 */
public void sendMyRuleDataToServer() {
	if(ruleOptPlayer == null) ruleOptPlayer = new RuleOptions();

	CustomProperties prop = new CustomProperties();
	ruleOptPlayer.writeProperty(prop, 0);
	String strRuleTemp = prop.encode("RuleData");
	String strRuleData = NetUtil.compressString(strRuleTemp);
	log.debug("RuleData uncompressed:" + strRuleTemp.length() + " compressed:" + strRuleData.length());

	// checkサム計算
	Adler32 checksumObj = new Adler32();
	checksumObj.update(NetUtil.stringToBytes(strRuleData));
	long sChecksum = checksumObj.getValue();

	// 送信
	netPlayerClient.send("ruledata\t" + sChecksum + "\t" + strRuleData + "\n");
}
 
開發者ID:PoochyEXE,項目名稱:nullpomino,代碼行數:21,代碼來源:NetLobbyFrame.java

示例11: calculateChecksum

import java.util.zip.Adler32; //導入方法依賴的package包/類
public static long calculateChecksum(CallFrame msg, long digestSeed) {

        // TODO: this is bad
        ByteBuf payloadCopy = msg.getPayload().slice();
        byte[] payloadBytes = new byte[msg.getPayloadSize()];
        payloadCopy.readBytes(payloadBytes);

        switch (msg.getChecksumType()) {

            case Adler32:
                Adler32 f = new Adler32();
                f.update((int) digestSeed);
                f.update(payloadBytes);
                return f.getValue();
            case FarmhashFingerPrint32:
            case NoChecksum:
            case CRC32C:
            default:
                return 0;
        }

    }
 
開發者ID:uber,項目名稱:tchannel-java,代碼行數:23,代碼來源:Checksums.java

示例12: test_getAdler

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * @tests java.util.zip.Deflater#getAdler()
 */
public void test_getAdler() {
	byte byteArray[] = { 'a', 'b', 'c', 1, 2, 3 };
	byte outPutBuf[] = new byte[100];
	Deflater defl = new Deflater();

	// getting the checkSum value using the Adler
	defl.setInput(byteArray);
	defl.finish();
	while (!defl.finished()) {
           defl.deflate(outPutBuf);
       }
	long checkSumD = defl.getAdler();
	defl.end();

	// getting the checkSum value through the Adler32 class
	Adler32 adl = new Adler32();
	adl.update(byteArray);
	long checkSumR = adl.getValue();
	assertEquals(
               "The checksum value returned by getAdler() is not the same as the checksum returned by creating the adler32 instance",
               checkSumD, checkSumR);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:26,代碼來源:DeflaterTest.java

示例13: test_getAdler

import java.util.zip.Adler32; //導入方法依賴的package包/類
/**
 * @tests java.util.zip.Inflater#getAdler()
 */
public void test_getAdler() {
	// test method of java.util.zip.inflater.getAdler()
	byte dictionaryArray[] = { 'e', 'r', 't', 'a', 'b', 2, 3 };

	Inflater inflateDiction = new Inflater();
	inflateDiction.setInput(outPutDiction);
	if (inflateDiction.needsDictionary() == true) {
		// getting the checkSum value through the Adler32 class
		Adler32 adl = new Adler32();
		adl.update(dictionaryArray);
		long checkSumR = adl.getValue();
		assertTrue(
				"the checksum value returned by getAdler() is not the same as the checksum returned by creating the adler32 instance",
				checkSumR == inflateDiction.getAdler());
	}
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:20,代碼來源:InflaterTest.java

示例14: calculCheckSum

import java.util.zip.Adler32; //導入方法依賴的package包/類
private Long calculCheckSum(Object[] r) throws Exception {
	Long retval;
	StringBuffer Buff = new StringBuffer();

	// Loop through fields
	for (int i = 0; i < data.fieldnr; i++) {
		String fieldvalue = getInputRowMeta().getString(r, data.fieldnrs[i]);
		Buff.append(fieldvalue);
	}

	if (meta.getCheckSumType().equals(CheckSumMeta.TYPE_CRC32)) {
		CRC32 crc32 = new CRC32();
		crc32.update(Buff.toString().getBytes());
		retval = new Long(crc32.getValue());
	} else {
		Adler32 adler32 = new Adler32();
		adler32.update(Buff.toString().getBytes());
		retval = new Long(adler32.getValue());
	}

	return retval;
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:23,代碼來源:CheckSum.java

示例15: calculCheckSum

import java.util.zip.Adler32; //導入方法依賴的package包/類
private Long calculCheckSum(Object[] r) throws Exception {
	Long retval;
	StringBuffer Buff = new StringBuffer();

	// Loop through fields
	for (int i = 0; i < data.fieldnr; i++) {
		String fieldvalue = getInputRowMeta()
				.getString(r, data.fieldnrs[i]);
		Buff.append(fieldvalue);
	}

	if (meta.getCheckSumType().equals("CRC32")) {
		CRC32 crc32 = new CRC32();
		crc32.update(Buff.toString().getBytes());
		retval = new Long(crc32.getValue());
	} else {
		Adler32 adler32 = new java.util.zip.Adler32();
		adler32.update(Buff.toString().getBytes());
		retval = new Long(adler32.getValue());
	}

	return retval;
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:24,代碼來源:CheckSum.java


注:本文中的java.util.zip.Adler32.getValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。