List of usage examples for java.lang Integer toHexString
public static String toHexString(int i)
From source file:MainClass.java
public static void main(String args[]) throws Exception { MessageDigest m = MessageDigest.getInstance("MD5"); m.update("test".getBytes()); byte s[] = m.digest(); String result = ""; for (int i = 0; i < s.length; i++) { result += Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6); }//from w w w . ja v a 2 s. c o m System.out.println(result); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { SecretKeySpec k = new SecretKeySpec("1234".getBytes(), "HMACSHA1"); Mac m = Mac.getInstance("HmacMD5"); m.init(k);//from ww w . j a v a 2 s. c o m m.update("test".getBytes("UTF8")); byte s[] = m.doFinal(); for (int i = 0; i < s.length; i++) { System.out.print(Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6)); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { MessageDigest m = MessageDigest.getInstance("MD5"); FileInputStream fin = new FileInputStream(args[0]); DigestInputStream din = new DigestInputStream(fin, m); while (din.read() != -1) ;/*from w ww. j a va2s .c o m*/ byte s[] = m.digest(); for (int i = 0; i < s.length; i++) { System.out.print(Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6)); } }
From source file:Main.java
public static void main(String args[]) throws IOException { File file = new File("your file path.jpg"); BufferedImage image = ImageIO.read(file); for (int i = 0; i < image.getHeight(); i++) { for (int j = 0; j < image.getWidth(); j++) { int color = image.getRGB(j, i); // convert the color to a readable format String clr = Integer.toHexString(color).substring(2); System.out.println(clr); }/* ww w. j a v a 2 s .c o m*/ } }
From source file:IntToLongCompressor.java
public static void main(String[] args) { int x = -23664; int y = -6543; System.out.println("x= " + Integer.toHexString(x)); System.out.println("y= " + Integer.toHexString(y)); long pack = pack(x, y); System.out.println("pack= " + Long.toHexString(pack)); int x2 = unpackX(pack); System.out.println("x2= " + Integer.toHexString(x2)); int y2 = unpackY(pack); System.out.println("y2= " + Integer.toHexString(y2)); testAll();/*from w w w .ja v a 2 s .c om*/ }
From source file:algoritmorsa_md5.MD5.java
/** * @param args the command line arguments *///from w w w . j a v a 2s .c om public static void main(String[] args) throws NoSuchAlgorithmException { // TODO code application logic here MessageDigest md = MessageDigest.getInstance(MessageDigestAlgorithms.MD5); md.update("yesica".getBytes()); byte[] digest = md.digest(); for (byte b : digest) { System.out.println(Integer.toHexString(0xFF & b)); } System.out.println(); byte[] encoded = Base64.encodeBase64(digest); System.out.println(new String(encoded)); }
From source file:MouseButtonState.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); Listener listener = new Listener() { public void handleEvent(Event e) { String string = "Unknown"; switch (e.type) { case SWT.MouseDown: string = "DOWN"; break; case SWT.MouseMove: string = "MOVE"; break; case SWT.MouseUp: string = "UP"; break; }/*from w w w .j a v a 2s. c o m*/ string += ": button: " + e.button + ", "; string += "stateMask=0x" + Integer.toHexString(e.stateMask); if ((e.stateMask & SWT.BUTTON1) != 0) string += " BUTTON1"; if ((e.stateMask & SWT.BUTTON2) != 0) string += " BUTTON2"; if ((e.stateMask & SWT.BUTTON3) != 0) string += " BUTTON3"; if ((e.stateMask & SWT.BUTTON4) != 0) string += " BUTTON4"; if ((e.stateMask & SWT.BUTTON5) != 0) string += " BUTTON5"; System.out.println(string); } }; shell.addListener(SWT.MouseDown, listener); shell.addListener(SWT.MouseMove, listener); shell.addListener(SWT.MouseUp, listener); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet62.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 62"); Listener listener = e -> {// ww w.j ava2 s. c o m String string = "Unknown"; switch (e.type) { case SWT.MouseDown: string = "DOWN"; break; case SWT.MouseMove: string = "MOVE"; break; case SWT.MouseUp: string = "UP"; break; } string += ": button: " + e.button + ", "; string += "stateMask=0x" + Integer.toHexString(e.stateMask) + stateMask(e.stateMask) + ", x=" + e.x + ", y=" + e.y; if ((e.stateMask & SWT.BUTTON1) != 0) string += " BUTTON1"; if ((e.stateMask & SWT.BUTTON2) != 0) string += " BUTTON2"; if ((e.stateMask & SWT.BUTTON3) != 0) string += " BUTTON3"; if ((e.stateMask & SWT.BUTTON4) != 0) string += " BUTTON4"; if ((e.stateMask & SWT.BUTTON5) != 0) string += " BUTTON5"; System.out.println(string); }; shell.addListener(SWT.MouseDown, listener); shell.addListener(SWT.MouseMove, listener); shell.addListener(SWT.MouseUp, listener); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet324.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 324"); Listener listener = e -> {/* www.j av a2s . c o m*/ String string = "Unknown"; switch (e.type) { case SWT.MouseDoubleClick: string = "DOUBLE-CLICK"; break; case SWT.MouseDown: string = "DOWN"; break; case SWT.MouseMove: string = "MOVE"; break; case SWT.MouseUp: string = "UP"; break; case SWT.MouseEnter: string = "ENTER"; break; case SWT.MouseExit: string = "EXIT"; break; case SWT.MouseVerticalWheel: string = "WHEEL VERTICAL"; break; case SWT.MouseHorizontalWheel: string = "WHEEL HORIZONTAL"; break; } string += " - button=" + e.button + ", "; string += "stateMask=0x" + Integer.toHexString(e.stateMask) + stateMask(e.stateMask); string += "location=(" + e.x + ", " + e.y + "), "; if (e.type == SWT.MouseVerticalWheel) { string += "detail="; string += e.detail == SWT.SCROLL_PAGE ? "SCROLL_PAGE, " : "SCROLL_LINE, "; } string += "count=" + e.count + ", widget=" + e.widget; System.out.println(string); }; shell.addListener(SWT.MouseDoubleClick, listener); shell.addListener(SWT.MouseDown, listener); shell.addListener(SWT.MouseMove, listener); shell.addListener(SWT.MouseUp, listener); shell.addListener(SWT.MouseEnter, listener); shell.addListener(SWT.MouseExit, listener); shell.addListener(SWT.MouseWheel, listener); shell.addListener(SWT.MouseHorizontalWheel, listener); Button button = new Button(shell, SWT.PUSH); button.setBounds(10, 10, 100, 100); button.addListener(SWT.MouseDoubleClick, listener); button.addListener(SWT.MouseDown, listener); button.addListener(SWT.MouseMove, listener); button.addListener(SWT.MouseUp, listener); button.addListener(SWT.MouseEnter, listener); button.addListener(SWT.MouseExit, listener); button.addListener(SWT.MouseWheel, listener); button.addListener(SWT.MouseHorizontalWheel, listener); shell.setSize(240, 240); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:codeswarm.processing.ColorTest.java
public static void main(String[] args) { ColorTest ct = new ColorTest(); logger.debug("input=" + args[0]); ct.loadProperty(args[0]);//from ww w . jav a 2 s .co m //logger.debug( "regex=" + ct.expr ); logger.debug("color1=" + Integer.toHexString(ct.c1)); logger.debug("color2=" + Integer.toHexString(ct.c2)); }