本文整理汇总了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;
}
}
示例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;
}
}
示例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();
}
示例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();
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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 );
}
示例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;
}
}
示例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");
}
示例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;
}
}
示例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);
}
示例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());
}
}
示例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;
}
示例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;
}