本文整理汇总了Java中fr.cryptohash.Digest.getDigestLength方法的典型用法代码示例。如果您正苦于以下问题:Java Digest.getDigestLength方法的具体用法?Java Digest.getDigestLength怎么用?Java Digest.getDigestLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fr.cryptohash.Digest
的用法示例。
在下文中一共展示了Digest.getDigestLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: speedUnit
import fr.cryptohash.Digest; //导入方法依赖的package包/类
private static long speedUnit(Digest dig, int j,
byte[] buf, int len, long num)
{
int dlen = dig.getDigestLength();
long orig = System.currentTimeMillis();
while (num -- > 0) {
dig.update(buf, 0, len);
dig.digest(buf, j, dlen);
if ((j += dlen) > (buf.length - dlen))
j = 0;
}
long end = System.currentTimeMillis();
return end - orig;
}
示例2: speedLong
import fr.cryptohash.Digest; //导入方法依赖的package包/类
private static long speedLong(Digest dig, byte[] buf, int len, long num)
{
byte[] out = new byte[dig.getDigestLength()];
long orig = System.currentTimeMillis();
while (num -- > 0) {
dig.update(buf, 0, len);
}
long end = System.currentTimeMillis();
dig.digest(out, 0, out.length);
return end - orig;
}
示例3: speed
import fr.cryptohash.Digest; //导入方法依赖的package包/类
private static void speed(String name, Digest dig)
{
System.out.println("Speed test: " + name);
byte[] buf = new byte[8192];
for (int i = 0; i < buf.length; i ++)
buf[i] = 'a';
int dlen = dig.getDigestLength();
int j = 0;
long num = 2L;
for (int clen = 16;; clen <<= 2) {
if (clen == 4096) {
clen = 8192;
if (num > 1L)
num >>= 1;
}
long tt;
for (;;) {
tt = speedUnit(dig, j, buf, clen, num);
j += dlen;
if (j > (buf.length - dlen))
j = 0;
if (tt > 6000L) {
if (num <= 1L)
break;
num >>= 1L;
} else if (tt < 2000L) {
num += num;
} else {
break;
}
}
long tlen = (long)clen * num;
long div = 10L * tt;
long rate = (tlen + (div - 1) / 2) / div;
System.out.println("message length = "
+ formatLong((long)clen, 5)
+ " -> "
+ prependSpaces(Long.toString(rate / 100L), 4)
+ "."
+ prependZeroes(Long.toString(rate % 100L), 2)
+ " MBytes/s");
if (clen == 8192) {
tt = speedLong(dig, buf, clen, num);
tlen = (long)clen * num;
div = 10L * tt;
rate = (tlen + (div - 1) / 2) / div;
System.out.println("long messages -> "
+ prependSpaces(
Long.toString(rate / 100L), 4)
+ "."
+ prependZeroes(
Long.toString(rate % 100L), 2)
+ " MBytes/s");
break;
}
if (num > 4L)
num >>= 2;
}
}