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


Java DatatypeConverter.printHexBinary方法代码示例

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


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

示例1: getSha1Fingerprint

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@Override
public String getSha1Fingerprint(X509Certificate cert) throws NoSuchAlgorithmException, CertificateEncodingException, IllegalArgumentException {

    if(cert == null) {
        throw new IllegalArgumentException("Provided certificate is empty");
    }

    MessageDigest md = MessageDigest.getInstance("SHA-1");
    byte[] der = cert.getEncoded();
    md.update(der);
    byte[] digest = md.digest();
    return DatatypeConverter.printHexBinary(digest);
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:14,代码来源:X509TrustManagerFactory.java

示例2: getKeyHex

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@Override
public String getKeyHex() throws EncryptionException{
    String hexKey = null;
    try {
        String aesCtrPassword = loadKeystorePasswordForAESCTRKey();

        if(StringUtils.isBlank(aesCtrPassword)) {
            throw new Exception("Keystore password not found in security properties file");
        }

        hexKey = KeyStoreProvider.getInstance().getPassword("AesCtrKey", aesCtrPassword);

        if (StringUtils.isBlank(hexKey)) {
            hexKey = DatatypeConverter.printHexBinary(KeyGenerator.getInstance("AES").generateKey().getEncoded());
            KeyStoreProvider.getInstance().putPassword("AesCtrKey", hexKey, aesCtrPassword);
        }
    } catch (Exception e) {
        LOG.error("Error encrypting plainText", e);
        throw new EncryptionException("Failed to get encryption key", e);
    }

    return hexKey;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:24,代码来源:AESCTREncryption.java

示例3: toString

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@Override
public String toString () {
    val result = new StringBuilder('\n');

    size.mark();
    result.append("size: ").append(size.getShort(0)).append('\n');
    size.reset();

    id.mark();
    result.append("id: ").append(id.getLong(0)).append('\n');
    id.reset();

    val to = body.position() != 0
             ? body.position()
             : body.limit();

    val array = Arrays.copyOfRange(body.array(), 0, to);
    val hexString = DatatypeConverter.printHexBinary(array);
    return result.append("body: ").append(hexString).toString();
}
 
开发者ID:xxlabaza,项目名称:ping,代码行数:21,代码来源:Message.java

示例4: digestHex

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public static String digestHex(String str) {
	try {
		MessageDigest md = MessageDigest.getInstance("SHA-512");
		byte[] data = md.digest(str.getBytes());
		return DatatypeConverter.printHexBinary(data);
	} catch (NoSuchAlgorithmException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:shimohq,项目名称:sdk-java-demo,代码行数:10,代码来源:Sign.java

示例5: EncryptRC4

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public static String EncryptRC4(String input, String key) {
    // encode input
    input = DatatypeConverter.printBase64Binary(input.getBytes());
    //input = DatatypeConverter.printHexBinary(input.getBytes());

    RC4 rc4 = new RC4(key.getBytes());
    byte[] ciphertext = rc4.encrypt(input.getBytes());

    // encode encrypted input
    //return DatatypeConverter.printBase64Binary(ciphertext);
    return DatatypeConverter.printHexBinary(ciphertext);
}
 
开发者ID:richkmeli,项目名称:Richkware-Manager-Client,代码行数:13,代码来源:Crypto.java

示例6: hash

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@Override
public String hash(CliArguments cliArguments) {
    try {
        PBEKeySpec keySpec = new PBEKeySpec(cliArguments.password().toCharArray(), cliArguments.salt().getBytes(), cliArguments.iterations(), cliArguments.keyLength());
        SecretKeyFactory factory = SecretKeyFactory.getInstance(cliArguments.algorithm().getName());

        final String hashedPasswd = DatatypeConverter.printHexBinary(factory.generateSecret(keySpec).getEncoded());

        return format("%s=$%s$%s$%s$%s$%s", cliArguments.username(), cliArguments.algorithm().getName(), cliArguments.iterations(), cliArguments.keyLength(), cliArguments.salt(), hashedPasswd);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:gocd,项目名称:gocd-filebased-authentication-plugin,代码行数:14,代码来源:PBKDF2Provider.java

示例7: getChecksum

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public static String getChecksum(InputStream inputStream) {
    try {
        byte[] buffer = new byte[8192];
        MessageDigest md = MessageDigest.getInstance(CHECKSUM_ALGORITHM);
        DigestInputStream dis = new DigestInputStream(inputStream, md);
        try {
            while (dis.read(buffer) != -1) ;
        } finally {
            dis.close();
        }
        return DatatypeConverter.printHexBinary(md.digest());
    } catch (Throwable e) {
        return null;
    }
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:16,代码来源:FileUtil.java

示例8: hashWord

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private void hashWord(MessageDigest msgDigest, String word) {
    try {
        byte[] digest = msgDigest.digest(word.getBytes("UTF-8"));
        String hex = DatatypeConverter.printHexBinary(digest);
        Item item = new Item(hex.toLowerCase(), word);
        // waits if queue is full
        queue.put(item);
    } catch (UnsupportedEncodingException | InterruptedException e) {
        e.printStackTrace();
    }
}
 
开发者ID:jmblixt3,项目名称:Clash-Royale,代码行数:12,代码来源:Producer.java

示例9: firewallMessage

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
 * Method to execute firewall policy on target Diameter message.
 * 
 * @param origin_asctn Origin SCTP association which received the message
 * @param payloadProtocolId SCTP payload id
 * @param streamNumber SCTP stream number
 * @param message Original Diameter message
 * @param reason the reason of discarding the message
 * @param lua_hm the LUA parameters, decoded from the message
 */
private void firewallMessage(Association origin_asctn, int payloadProtocolId, int streamNumber, Message message, String reason, HashMap<String, String> lua_hm) {
    String firewallPolicy = "";
    if (DiameterFirewallConfig.firewallPolicy == DiameterFirewallConfig.FirewallPolicy.DROP_SILENTLY) {
        firewallPolicy = "DROP_SILENTLY";
    } else if (DiameterFirewallConfig.firewallPolicy == DiameterFirewallConfig.FirewallPolicy.DROP_WITH_DIAMETER_ERROR) {
        firewallPolicy = "DROP_WITH_DIAMETER_ERROR";
        
        Answer answer = ((IMessage)(message)).createAnswer(ResultCode.UNABLE_TO_DELIVER);
        sendDiameterMessage(origin_asctn, payloadProtocolId, streamNumber, answer, false, lua_hm);
    } else if (DiameterFirewallConfig.firewallPolicy == DiameterFirewallConfig.FirewallPolicy.DNAT_TO_HONEYPOT && dnat_sessions != null
            && message.getAvps() != null
            && ((message.getAvps().getAvp(Avp.ORIGIN_HOST) != null)
            || (message.getAvps().getAvp(Avp.ORIGIN_REALM) != null) 
            && (message.getAvps().getAvp(Avp.DESTINATION_HOST) != null
            || (message.getAvps().getAvp(Avp.DESTINATION_REALM) != null)))
            ) {
        firewallPolicy = "DNAT_TO_HONEYPOT";
        
        String session_key = lua_hm.get("diameter_orig_host") + ":" + lua_hm.get("diameter_orig_realm");
        dnat_sessions.put(session_key, lua_hm.get("diameter_dest_host") + ":" + lua_hm.get("diameter_dest_realm"));
        
        message.getAvps().removeAvp(Avp.DESTINATION_REALM);
        message.getAvps().removeAvp(Avp.DESTINATION_HOST);
        // TODO usa raw AVP encoding, because aaa:// is added by jDiameter
        //try {
        message.getAvps().addAvp(Avp.DESTINATION_REALM, DiameterFirewallConfig.honeypot_diameter_realm, true, false, true);
        message.getAvps().addAvp(Avp.DESTINATION_HOST, DiameterFirewallConfig.honeypot_diameter_host, true, false, true);
        sendDiameterMessage(origin_asctn, payloadProtocolId, streamNumber, message, true, lua_hm);
        /*} catch (URISyntaxException ex) {
            java.util.logging.Logger.getLogger(DiameterFirewall.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnknownServiceException ex) {
            java.util.logging.Logger.getLogger(DiameterFirewall.class.getName()).log(Level.SEVERE, null, ex);
        }*/
        

    } else if (DiameterFirewallConfig.firewallPolicy == DiameterFirewallConfig.FirewallPolicy.ALLOW) {
        firewallPolicy = "ALLOW";
        sendDiameterMessage(origin_asctn, payloadProtocolId, streamNumber, message, true, lua_hm);
    }
    
    logger.info("Blocked message: Reason [" + reason + "] Policy [" + firewallPolicy + "] ");
            
    JSONObject json_alert = new JSONObject();
    logger.debug("============ LUA variables ============");
    // mThreat alerting
    MessageDigest digest;
    try {
        digest = MessageDigest.getInstance("SHA-256");
    
        for (String key : lua_hm.keySet()) {
            logger.debug(key + ": " + lua_hm.get(key));

            String value = lua_hm.get(key);
            // Anonymize MSISDN, IMSI
            if (key.equals("diameter_imsi") || key.equals("diameter_msisdn")) {
                // add salt before hashing
                value = DiameterFirewallConfig.mthreat_salt + value;
                value = DatatypeConverter.printHexBinary(digest.digest(value.getBytes(StandardCharsets.UTF_8)));
            } 
            json_alert.put(key, value);
        }
        mThreat_alerts.add(json_alert.toJSONString());
    } catch (NoSuchAlgorithmException ex) {
        java.util.logging.Logger.getLogger(DiameterFirewall.class.getName()).log(Level.SEVERE, null, ex);
    }
    
    return;
}
 
开发者ID:P1sec,项目名称:SigFW,代码行数:79,代码来源:DiameterFirewall.java

示例10: bytestoHex

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private String bytestoHex(byte[] hash){
    return DatatypeConverter.printHexBinary(hash);
}
 
开发者ID:TheMagicFingers,项目名称:MuralEscolar,代码行数:4,代码来源:Hash.java

示例11: marshal

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

示例12: md5

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private String md5(final String string) {
    return DatatypeConverter.printHexBinary(getMessageDigest()
            .digest(string.getBytes(StandardCharsets.UTF_8))
    );
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:6,代码来源:AllureJbehave.java

示例13: getString

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public String getString() {
    return DatatypeConverter.printHexBinary(id);
}
 
开发者ID:kazigk,项目名称:wail,代码行数:4,代码来源:WAILToken.java

示例14: Ingest

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
 * Creates a new Ingest with data to ingest.
 * Will read the stream, store it in a temp file.
 * @param in data to ingest.
 * @throws ODataException an error occured.
 */
public Ingest(InputStream in) throws ODataException
{
   uploader = SECURITY_SERVICE.getCurrentUser();

   // write file to temp file
   try
   {
      temp_file = Files.createTempFile(WorkingDirectory.getTempDirectoryFile().toPath(), null, ".ingest_data");
      LOGGER.info(String.format("User %s uploading data to %s",
            uploader.getUsername(), temp_file.toString()));
      try (OutputStream os = Files.newOutputStream(temp_file))
      {
         // Computes the MD5 hash of the uploaded file as it is written to disk
         MessageDigest md = MessageDigest.getInstance("MD5");
         DigestOutputStream md5_os = new DigestOutputStream(os, md);
         BufferedOutputStream bos = new BufferedOutputStream(md5_os);

         int byt3;
         while ((byt3 = in.read()) != -1)
         {
            bos.write(byt3);
         }
         bos.flush();
         this.md5 = DatatypeConverter.printHexBinary(md5_os.getMessageDigest().digest());
      }
   }
   catch (IOException | NoSuchAlgorithmException e)
   {
      LOGGER.fatal(e);
      throw new ODataException("A system error occured", e);
   }

   id = CURSOR.getAndIncrement();
   if (UPLOADS.put(id, this) != null)
   {
      LOGGER.fatal("Race condition!");
   }

   setStatus(Status.WAITING_FOR_METADATA);
   statusMessage = "Set the Filename property to insert the product in the ingestion pipeline";
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:48,代码来源:Ingest.java

示例15: toHexString

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public static String toHexString(byte[] bytes) {
    return DatatypeConverter.printHexBinary(bytes);
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:4,代码来源:FormatUtils.java


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