本文整理汇总了Java中nxt.crypto.HashFunction.getHashFunction方法的典型用法代码示例。如果您正苦于以下问题:Java HashFunction.getHashFunction方法的具体用法?Java HashFunction.getHashFunction怎么用?Java HashFunction.getHashFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nxt.crypto.HashFunction
的用法示例。
在下文中一共展示了HashFunction.getHashFunction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HashSolver
import nxt.crypto.HashFunction; //导入方法依赖的package包/类
private HashSolver(byte algorithm, long currencyId, long accountId, long counter, long units, long nonce,
byte[] target, int poolSize) {
this.hashFunction = HashFunction.getHashFunction(algorithm);
this.currencyId = currencyId;
this.accountId = accountId;
this.counter = counter;
this.units = units;
this.nonce = nonce;
this.target = target;
this.poolSize = poolSize;
}
示例2: getHashFunction
import nxt.crypto.HashFunction; //导入方法依赖的package包/类
public static HashFunction getHashFunction(byte code) {
try {
HashFunction hashFunction = HashFunction.getHashFunction(code);
if (acceptedHashFunctions.contains(hashFunction)) {
return hashFunction;
}
} catch (IllegalArgumentException ignore) {}
return null;
}
示例3: processRequest
import nxt.crypto.HashFunction; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws ParameterException {
byte algorithm = ParameterParser.getByte(req, "hashAlgorithm", (byte) 0, Byte.MAX_VALUE, false);
HashFunction hashFunction = null;
try {
hashFunction = HashFunction.getHashFunction(algorithm);
} catch (IllegalArgumentException ignore) {}
if (hashFunction == null) {
return JSONResponses.INCORRECT_HASH_ALGORITHM;
}
boolean secretIsText = "true".equalsIgnoreCase(req.getParameter("secretIsText"));
byte[] secret;
try {
secret = secretIsText ? Convert.toBytes(req.getParameter("secret"))
: Convert.parseHexString(req.getParameter("secret"));
} catch (RuntimeException e) {
return JSONResponses.INCORRECT_SECRET;
}
if (secret == null || secret.length == 0) {
return JSONResponses.MISSING_SECRET;
}
JSONObject response = new JSONObject();
response.put("hash", Convert.toHexString(hashFunction.hash(secret)));
return response;
}
示例4: getHash
import nxt.crypto.HashFunction; //导入方法依赖的package包/类
public static byte[] getHash(byte algorithm, long nonce, long currencyId, long units, long counter, long accountId) {
HashFunction hashFunction = HashFunction.getHashFunction(algorithm);
return getHash(hashFunction, nonce, currencyId, units, counter, accountId);
}