当前位置: 首页>>代码示例>>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;未经允许,请勿转载。