本文整理汇总了Java中org.bouncycastle.util.encoders.Hex.decode方法的典型用法代码示例。如果您正苦于以下问题:Java Hex.decode方法的具体用法?Java Hex.decode怎么用?Java Hex.decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.util.encoders.Hex
的用法示例。
在下文中一共展示了Hex.decode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createParameters
import org.bouncycastle.util.encoders.Hex; //导入方法依赖的package包/类
protected X9ECParameters createParameters()
{
int m = 409;
int k = 87;
BigInteger a = BigInteger.valueOf(1);
BigInteger b = fromHex("0021A5C2C8EE9FEB5C4B9A753B7B476B7FD6422EF1F3DD674761FA99D6AC27C8A9A197B272822F6CD57A55AA4F50AE317B13545F");
byte[] S = Hex.decode("4099B5A457F9D69F79213D094C4BCD4D4262210B");
BigInteger n = fromHex("010000000000000000000000000000000000000000000000000001E2AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173");
BigInteger h = BigInteger.valueOf(2);
ECCurve curve = new ECCurve.F2m(m, k, a, b, n, h);
//ECPoint G = curve.decodePoint(Hex.decode("03"
//+ "015D4860D088DDB3496B0C6064756260441CDE4AF1771D4DB01FFE5B34E59703DC255A868A1180515603AEAB60794E54BB7996A7"));
ECPoint G = curve.decodePoint(Hex.decode("04"
+ "015D4860D088DDB3496B0C6064756260441CDE4AF1771D4DB01FFE5B34E59703DC255A868A1180515603AEAB60794E54BB7996A7"
+ "0061B1CFAB6BE5F32BBFA78324ED106A7636B9C5A7BD198D0158AA4F5488D08F38514F1FDF4B4F40D2181B3681C364BA0273C706"));
return new X9ECParameters(curve, G, n, h, S);
}
示例2: createParameters
import org.bouncycastle.util.encoders.Hex; //导入方法依赖的package包/类
protected X9ECParameters createParameters()
{
BigInteger c2m191v1n = new BigInteger("40000000000000000000000004A20E90C39067C893BBB9A5", 16);
BigInteger c2m191v1h = BigInteger.valueOf(2);
ECCurve c2m191v1 = new ECCurve.F2m(
191,
9,
new BigInteger("2866537B676752636A68F56554E12640276B649EF7526267", 16),
new BigInteger("2E45EF571F00786F67B0081B9495A3D95462F5DE0AA185EC", 16),
c2m191v1n, c2m191v1h);
return new X9ECParameters(
c2m191v1,
c2m191v1.decodePoint(
Hex.decode("0236B3DAF8A23206F9C4F299D7B21A9C369137F2C84AE1AA0D")),
c2m191v1n, c2m191v1h,
Hex.decode("4E13CA542744D696E67687561517552F279A8C84"));
}
示例3: calculateGenerator_FIPS186_3_Verifiable
import org.bouncycastle.util.encoders.Hex; //导入方法依赖的package包/类
private static BigInteger calculateGenerator_FIPS186_3_Verifiable(Digest d, BigInteger p, BigInteger q,
byte[] seed, int index)
{
// A.2.3 Verifiable Canonical Generation of the Generator g
BigInteger e = p.subtract(ONE).divide(q);
byte[] ggen = Hex.decode("6767656E");
// 7. U = domain_parameter_seed || "ggen" || index || count.
byte[] U = new byte[seed.length + ggen.length + 1 + 2];
System.arraycopy(seed, 0, U, 0, seed.length);
System.arraycopy(ggen, 0, U, seed.length, ggen.length);
U[U.length - 3] = (byte)index;
byte[] w = new byte[d.getDigestSize()];
for (int count = 1; count < (1 << 16); ++count)
{
inc(U);
hash(d, U, w);
BigInteger W = new BigInteger(1, w);
BigInteger g = W.modPow(e, p);
if (g.compareTo(TWO) >= 0)
{
return g;
}
}
return null;
}
示例4: testGetRSAPublicKey
import org.bouncycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test
public void testGetRSAPublicKey() {
byte[] n = Hex.decode("A9E167983F39D55FF2A093415EA6798985C8355D9A915BFB1D01DA197026170FBDA522D035856D7A986614415CCFB7B7083B09C991B81969376DF9651E7BD9A93324A37F3BBBAF460186363432CB07035952FC858B3104B8CC18081448E64F1CFB5D60C4E05C1F53D37F53D86901F105F87A70D1BE83C65F38CF1C2CAA6AA7EB");
byte[] e = Hex.decode("010001");
Algorithm alg = Algorithm.RS256;
RsaKey rsaPublicKey = new RsaKey(alg, n, e);
try {
Crypto.getRSAPublicKey(rsaPublicKey);
} catch (WebAuthnException ex) {
fail("WebAuthnException: " + ex.getMessage());
}
}
示例5: decrypt
import org.bouncycastle.util.encoders.Hex; //导入方法依赖的package包/类
/**
* Decrypt.
*
* @param instr the instr
* @return the string
* @throws GeneralSecurityException the general security exception
*/
@Override
public String decrypt(String instr) throws GeneralSecurityException {
byte[] in;
if (instr.startsWith(CmsCrypto.ENC_PREFIX)) {
in = Hex.decode(instr.substring(CmsCrypto.ENC_PREFIX.length()));
} else {
in = Hex.decode(instr);
}
byte[] out = decryptor.doFinal(in);
return new String(out);
}
示例6: execute0
import org.bouncycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Override
protected Object execute0() throws Exception {
P11Slot slot = getSlot(moduleName, slotIndex);
byte[] idBytes = null;
if (id != null) {
idBytes = Hex.decode(id);
}
int num = slot.removeObjects(idBytes, label);
println("deleted " + num + " objects");
return null;
}
示例7: performDecrypt
import org.bouncycastle.util.encoders.Hex; //导入方法依赖的package包/类
private void performDecrypt(byte[] key)
{
// initialise the cipher for decryption
cipher.init(false, new KeyParameter(key));
/*
* As the decryption is from our preformatted file,
* and we know that it's a hex encoded format, then
* we wrap the InputStream with a BufferedReader
* so that we can read it easily.
*/
BufferedReader br = new BufferedReader(new InputStreamReader(in));
/*
* now, read the file, and output the chunks
*/
try
{
int outL;
byte[] inblock = null;
byte[] outblock = null;
String rv = null;
while ((rv = br.readLine()) != null)
{
inblock = Hex.decode(rv);
outblock = new byte[cipher.getOutputSize(inblock.length)];
outL = cipher.processBytes(inblock, 0, inblock.length,
outblock, 0);
/*
* Before we write anything out, we need to make sure
* that we've got something to write out.
*/
if (outL > 0)
{
out.write(outblock, 0, outL);
}
}
try
{
/*
* Now, process the bytes that are still buffered
* within the cipher.
*/
outL = cipher.doFinal(outblock, 0);
if (outL > 0)
{
out.write(outblock, 0, outL);
}
}
catch (CryptoException ce)
{
}
}
catch (IOException ioeread)
{
ioeread.printStackTrace();
}
}
示例8: fromHex
import org.bouncycastle.util.encoders.Hex; //导入方法依赖的package包/类
private static BigInteger fromHex(
String hex)
{
return new BigInteger(1, Hex.decode(hex));
}