当前位置: 首页>>代码示例>>Java>>正文


Java DatatypeConverter.parseHexBinary方法代码示例

本文整理汇总了Java中javax.xml.bind.DatatypeConverter.parseHexBinary方法的典型用法代码示例。如果您正苦于以下问题:Java DatatypeConverter.parseHexBinary方法的具体用法?Java DatatypeConverter.parseHexBinary怎么用?Java DatatypeConverter.parseHexBinary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.DatatypeConverter的用法示例。


在下文中一共展示了DatatypeConverter.parseHexBinary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToThreeBytes

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
 * Converts a number to three bytes.
 *
 * @param numberToConvert number to convert
 * @return given number as bytes
 */
public static byte[] convertToThreeBytes(int numberToConvert) {
    byte[] numInBytes = new byte[3];
    String s1 = Integer.toHexString(numberToConvert);
    if (s1.length() % 2 != 0) {
        s1 = "0" + s1;
    }
    byte[] hexas = DatatypeConverter.parseHexBinary(s1);
    if (hexas.length == 1) {
        numInBytes[0] = 0;
        numInBytes[1] = 0;
        numInBytes[2] = hexas[0];
    } else if (hexas.length == 2) {
        numInBytes[0] = 0;
        numInBytes[1] = hexas[0];
        numInBytes[2] = hexas[1];
    } else {
        numInBytes[0] = hexas[0];
        numInBytes[1] = hexas[1];
        numInBytes[2] = hexas[2];
    }
    return numInBytes;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:OspfUtil.java

示例2: decompress

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
   * Testing method for decompression of ewf file hex bytes
   * @param ewfHexStr any zlib compressed hex
   * @return decompressed string
   */
  protected static String decompress(String ewfHexStr) {
Inflater inflater = new Inflater();
byte[] input = DatatypeConverter.parseHexBinary(ewfHexStr);
inflater.setInput(input, 0, input.length);
String outputString = "empty";

byte[] result = new byte[input.length];
int resultLength;
try {
	resultLength = inflater.inflate(result);
	outputString = new String(result, 0, resultLength, "UTF-8");
} catch (DataFormatException | UnsupportedEncodingException e) {
	e.printStackTrace();
}
inflater.end();

return outputString;
  }
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:24,代码来源:CompressionTask.java

示例3: convertToTwoBytes

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
 * Converts an integer to two bytes.
 *
 * @param numberToConvert number to convert
 * @return numInBytes given number as bytes
 */
public static byte[] convertToTwoBytes(int numberToConvert) {

    byte[] numInBytes = new byte[2];
    String s1 = Integer.toHexString(numberToConvert);
    if (s1.length() % 2 != 0) {
        s1 = "0" + s1;
    }
    byte[] hexas = DatatypeConverter.parseHexBinary(s1);
    if (hexas.length == 1) {
        numInBytes[0] = 0;
        numInBytes[1] = hexas[0];
    } else {
        numInBytes[0] = hexas[0];
        numInBytes[1] = hexas[1];
    }
    return numInBytes;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:IsisUtil.java

示例4: DecryptAES

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public static String DecryptAES(String input, SecretKey key) throws CryptoException {
    // decode encrypted input
    //byte[] decoded = DatatypeConverter.parseBase64Binary(input);
    byte[] decoded = DatatypeConverter.parseHexBinary(input);

    byte[] plaintext = null;
    try {
        plaintext = AES.decrypt(decoded, key);
    } catch (Exception e) {
        throw new CryptoException(e);
    }


    // decode input
    decoded = DatatypeConverter.parseBase64Binary(new String(plaintext));
    return new String(decoded);
}
 
开发者ID:richkmeli,项目名称:Richkware-Manager-Client,代码行数:18,代码来源:Crypto.java

示例5: getStroke

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public static Stroke getStroke(String name, Stroke defaultStroke) {
    String val = getString(name);
    if (val == null)
        return defaultStroke;
    ByteArrayInputStream is = new ByteArrayInputStream(
            DatatypeConverter.parseHexBinary(val));
    try {
        return DataLoader.readStroke(is, new DataLoader.MemoryData());
    } catch (IOException e) {// shell never happen
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:14,代码来源:Options.java

示例6: convertToFourBytes

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
 * Converts a number to four bytes.
 *
 * @param numberToConvert number to convert
 * @return given number as bytes
 */
public static byte[] convertToFourBytes(long numberToConvert) {

    byte[] numInBytes = new byte[4];
    String s1 = Long.toHexString(numberToConvert);
    if (s1.length() % 2 != 0) {
        s1 = "0" + s1;
    }
    if (s1.length() == 16) {
        s1 = s1.substring(8, s1.length());
    }
    byte[] hexas = DatatypeConverter.parseHexBinary(s1);
    if (hexas.length == 1) {
        numInBytes[0] = 0;
        numInBytes[1] = 0;
        numInBytes[2] = 0;
        numInBytes[3] = hexas[0];
    } else if (hexas.length == 2) {
        numInBytes[0] = 0;
        numInBytes[1] = 0;
        numInBytes[2] = hexas[0];
        numInBytes[3] = hexas[1];
    } else if (hexas.length == 3) {
        numInBytes[0] = 0;
        numInBytes[1] = hexas[0];
        numInBytes[2] = hexas[1];
        numInBytes[3] = hexas[2];
    } else {
        numInBytes[0] = hexas[0];
        numInBytes[1] = hexas[1];
        numInBytes[2] = hexas[2];
        numInBytes[3] = hexas[3];
    }
    return numInBytes;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:OspfUtil.java

示例7: loadPrivateKey

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public static PrivateKey loadPrivateKey(String key64) throws GeneralSecurityException {
    byte[] clear = DatatypeConverter.parseHexBinary(key64);
    PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(clear);
    KeyFactory fact = KeyFactory.getInstance("RSA");
    PrivateKey priv = fact.generatePrivate(keySpec);
    Arrays.fill(clear, (byte) 0);
    return priv;
}
 
开发者ID:richkmeli,项目名称:Richkware-Manager-Client,代码行数:9,代码来源:Crypto.java

示例8: read

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@Override
public void read(javolution.xml.XMLFormat.InputElement xml, MSClassmark2Impl msClassmark2) throws XMLStreamException {
    String s = xml.getAttribute(DATA, DEFAULT_VALUE);
    if (s != null) {
        msClassmark2.data = DatatypeConverter.parseHexBinary(s);
    }
}
 
开发者ID:RestComm,项目名称:phone-simulator,代码行数:8,代码来源:MSClassmark2Impl.java

示例9: read

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@Override
public void read(javolution.xml.XMLFormat.InputElement xml, CUGInterlockImpl cugInterlock) throws XMLStreamException {
    String s = xml.getAttribute(DATA, DEFAULT_VALUE);
    if (s != null) {
        cugInterlock.data = DatatypeConverter.parseHexBinary(s);
    }
}
 
开发者ID:RestComm,项目名称:phone-simulator,代码行数:8,代码来源:CUGInterlockImpl.java

示例10: main

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    MessageDigest digest = MessageDigest.getInstance("SHA1");
    SecretKeySpec key = new SecretKeySpec(
        DatatypeConverter.parseHexBinary(
        "12345678123456781234567812345678"), "AES");

    // Run 'message' through streamEncrypt
    byte[] se = streamEncrypt(message, key, digest);
    // 'digest' already has the value from the stream, just finish the op
    byte[] sd = digest.digest();
    digest.reset();
    // Run 'message' through blockEncrypt
    byte[] be = blockEncrypt(message, key);
    // Take digest of encrypted blockEncrypt result
    byte[] bd = digest.digest(be);
    // Verify both returned the same value
    if (!Arrays.equals(sd, bd)) {
        System.err.println("Stream: "+DatatypeConverter.printHexBinary(se)+
            "\t Digest: "+DatatypeConverter.printHexBinary(sd));
        System.err.println("Block : "+DatatypeConverter.printHexBinary(be)+
            "\t Digest: "+DatatypeConverter.printHexBinary(bd));
        throw new Exception("stream & block encryption does not match");
    }

    digest.reset();
    // Sanity check: Decrypt separately from stream to verify operations
    String bm = (String) blockDecrypt(be, key);
    if (message.compareTo(bm) != 0) {
        System.err.println("Expected: "+message+"\nBlock:    "+bm);
        throw new Exception("Block decryption does not match expected");
    }

    // Have decryption and digest included in the object stream
    String sm = (String) streamDecrypt(se, key, digest);
    if (message.compareTo(sm) != 0) {
        System.err.println("Expected: "+message+"\nStream:   "+sm);
        throw new Exception("Stream decryption does not match expected.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:CipherStreamClose.java

示例11: addToCache

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private void addToCache(String hexString) throws IOException {
    byte[] encoding = DatatypeConverter.parseHexBinary(hexString);
    int[] ids = getIDs(encoding);
    int messageID = ids[0];
    List<byte[]> encodings = cache.get(messageID);
    if (encodings == null) {
        encodings = new ArrayList<>();
    }
    System.out.println("    adding LDAP " + getOperation(ids[1]) +
        " with message ID " + messageID + " to the cache");
    encodings.add(encoding);
    cache.put(messageID, encodings);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:LDAPServer.java

示例12: execute

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
void execute() throws IOException {
    final CodeResources codeResources = new CodeResources(resourceRules);

    if (!isBundle) {
        codeResourcesHash = new byte[20];
        codeResources256Hash = new byte[32];
    } else if (resourcesHashStr != null) {
        codeResourcesHash = DatatypeConverter.parseHexBinary(resourcesHashStr);
        codeResources256Hash = DatatypeConverter.parseHexBinary(resources256HashStr);
        if (infoPlistHashStr != null) {
            infoPlistHash = DatatypeConverter.parseHexBinary(infoPlistHashStr);
        }
        if (infoPlist256HashStr != null) {
            infoPlist256Hash = DatatypeConverter.parseHexBinary(infoPlist256HashStr);
        }
    } else {
        storeResourceFiles(codeResources);
        Pair<byte[], byte[]> codeResourcesHashPair = storeCodeResources(codeResources);
        codeResourcesHash = codeResourcesHashPair.first;
        codeResources256Hash = codeResourcesHashPair.second;
    }
    //This should be the only output from the program ever, it's used by codesign.py and any other output will cause codesign.py to stop working
    System.out.println(DatatypeConverter.printHexBinary(codeResourcesHash));
    System.out.println(DatatypeConverter.printHexBinary(codeResources256Hash));
    System.out.println(DatatypeConverter.printHexBinary(infoPlistHash));
    System.out.println(DatatypeConverter.printHexBinary(infoPlist256Hash));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:28,代码来源:ResourcePacker.java

示例13: EncryptionParameters

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private EncryptionParameters() throws KeyStoreProviderException, IOException {
	// get aliases/passwords to keystore from properties
	Properties properties = getProperties();
       String keyAlias = properties.getProperty("db.backup.key.alias");
       String keyPassword = properties.getProperty("db.backup.key.password");
       String ivAlias = properties.getProperty("db.backup.iv.alias");
       String ivPassword = properties.getProperty("db.backup.iv.password");

       // get key and iv from keystore
       this.key = KeyStoreProvider.getInstance().getSecretKey(keyAlias, keyPassword);
       this.iv = DatatypeConverter.parseHexBinary(KeyStoreProvider.getInstance().getPassword(ivAlias, ivPassword));
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:13,代码来源:BackupFileService.java

示例14: convertToFourBytes

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
 * Converts a number to four bytes.
 *
 * @param numberToConvert number to convert
 * @return numInBytes given number as bytes
 */
public static byte[] convertToFourBytes(long numberToConvert) {
    byte[] numInBytes = new byte[4];
    String s1 = Long.toHexString(numberToConvert);
    if (s1.length() % 2 != 0) {
        s1 = "0" + s1;
    }
    if (s1.length() == 16) {
        s1 = s1.substring(8, s1.length());
    }
    byte[] hexas = DatatypeConverter.parseHexBinary(s1);
    if (hexas.length == 1) {
        numInBytes[0] = 0;
        numInBytes[1] = 0;
        numInBytes[2] = 0;
        numInBytes[3] = hexas[0];
    } else if (hexas.length == 2) {
        numInBytes[0] = 0;
        numInBytes[1] = 0;
        numInBytes[2] = hexas[0];
        numInBytes[3] = hexas[1];
    } else if (hexas.length == 3) {
        numInBytes[0] = 0;
        numInBytes[1] = hexas[0];
        numInBytes[2] = hexas[1];
        numInBytes[3] = hexas[2];
    } else {
        numInBytes[0] = hexas[0];
        numInBytes[1] = hexas[1];
        numInBytes[2] = hexas[2];
        numInBytes[3] = hexas[3];
    }
    return numInBytes;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:40,代码来源:IsisUtil.java

示例15: unmarshal

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public byte[] unmarshal(String s) {
    if(s==null)     return null;
    return DatatypeConverter.parseHexBinary(s);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:HexBinaryAdapter.java


注:本文中的javax.xml.bind.DatatypeConverter.parseHexBinary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。