本文整理汇总了Java中com.sun.org.apache.xerces.internal.impl.dv.util.HexBin类的典型用法代码示例。如果您正苦于以下问题:Java HexBin类的具体用法?Java HexBin怎么用?Java HexBin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HexBin类属于com.sun.org.apache.xerces.internal.impl.dv.util包,在下文中一共展示了HexBin类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeMd5
import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin; //导入依赖的package包/类
private static CompletableFuture<String> computeMd5(Path path) {
return CompletableFuture.supplyAsync(() -> {
try {
MessageDigest md = MessageDigest.getInstance("MD5"); // Possibly use a different hashing algorithm
try (InputStream is = Files.newInputStream(path);
DigestInputStream dis = new DigestInputStream(is, md)) {
int readByte;
do {
readByte = dis.read();
} while(readByte != -1);
}
byte[] bytes = md.digest();
return HexBin.encode(bytes);
} catch (IOException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}, MineskinSponge.getInstance().getAsyncExecutor());
}
示例2: getActualValue
import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin; //导入依赖的package包/类
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
byte[] decoded = HexBin.decode(content);
if (decoded == null)
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "hexBinary"});
return new XHex(decoded);
}
示例3: initSecondPage
import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin; //导入依赖的package包/类
public void initSecondPage() {
components.clear();
TextButton back = new TextButton((Game.getWidth() - (TextButton.WIDTH + 40)) / 2 + 20, 320, "Zurück");
back.addClickEvent(new ClickEvent() {
@Override
public void trigger() {
initFirstPage();
}
});
components.add(back);
username = new InputField(back.getX(), back.getY() + TextButton.HEIGHT, TextButton.WIDTH, 40);
username.setAllowed("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890öäüÖÄÜß");
username.setHint("Benutzername");
components.add(username);
password = new InputField(back.getX(), back.getY() + TextButton.HEIGHT * 2, TextButton.WIDTH, 40);
password.setPassword(true);
String allowed = password.getAllowed();
allowed += ",;.:-_#'+*~!§$%&/()=?<>| ";
password.setAllowed(allowed);
password.setHint("Passwort");
components.add(password);
login = new TextButton(back.getX(), back.getY() + TextButton.HEIGHT * 3, "Anmelden");
login.enabled = false;
login.addClickEvent(new ClickEvent() {
@Override
public void trigger() {
try {
final String pw = new String(HexBin.encode(MessageDigest.getInstance("MD5").digest(password.getText().getBytes()))).toLowerCase();
Game.client.sendPacket(new Packet01Login(username.getText(), pw, Game.worldID));
Game.currentGame.addLayer(new LoadingLayer());
} catch (Exception e) {
e.printStackTrace();
}
}
});
components.add(login);
}
示例4: MD5
import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin; //导入依赖的package包/类
public static String MD5(byte[] b) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return HexBin.encode(md.digest(b));
}
示例5: toString
import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin; //导入依赖的package包/类
public synchronized String toString() {
if (canonical == null) {
canonical = HexBin.encode(data);
}
return canonical;
}
示例6: toSha1
import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin; //导入依赖的package包/类
public String toSha1(String input) {
mdSha1.reset();
mdSha1.update(input.getBytes());
return HexBin.encode(mdSha1.digest());
}
示例7: testNumericEncoder
import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin; //导入依赖的package包/类
public void testNumericEncoder() {
Encoders.Numeric enc = new Encoders.Numeric();
byte []bs = enc.encode((3.4456)).get(0);
assertEquals("400B9096BB98C7E3",HexBin.encode(enc.encode((3.4456d)).get(0)));
assertEquals("405C84B6",HexBin.encode(enc.encode((float)3.4456).get(0)));
assertTrue(HexBin.encode(enc.encode(3.4456).get(0)).compareTo(HexBin.encode(enc.encode((2.4456)).get(0))) > 0);
assertEquals("0000000000000005",HexBin.encode(enc.encode(5).get(0)));
}