come with me, on the way I'll explain.
SHA-1 em Java
import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class sha1it { public static void main(String[] args) throws NoSuchAlgorithmException { if (args.length==0) return; MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(args[0].getBytes()); byte[] newHash = md.digest(); StringBuffer newHashStringBuffer = new StringBuffer(); for ( int i = 0; i < newHash.length; i++ ) newHashStringBuffer.append(Integer.toHexString(newHash[i]&0xff)); System.out.println(newHashStringBuffer.toString()); } }
Vai calcular o SHA-1 do primeiro argumento da linha de comando:
$ java sha1it silveira
665fc8e2ed1b8aa1571a5c9d3e14d89bad4f0
Note que não é uma implementação pura do SHA-1. Simplesmente pedimos por essa implementação, que pode não estar disponível.
No comments yet.
No trackbacks yet.
The Caps Lock Java Socket Server
27 February, 2010 - 9:39 pm
Tags: caps lock, Java, programming, socket, upcase
Posted in english | No comments
Here is a simple server for those who are starting studying sockets or just needs a simple socket server example for reuse while writing your own behavior.
Features:
A client should enter a string and the server would answer the same string, with each symbol in up case, when possible.
Default port at 8080.
One client at time.
No multi [...]
Beware the locale
22 February, 2010 - 5:16 pm
Tags: development, i18n, Java, JUnit, locale, programming, String, teste unitário, toString, unit testing
Posted in english | No comments
Today I was programming a toString method for a class widely used in a application, using the very useful String.format that provides a C’s like printf formatter.
@Override
public String toString() {
return String.format("VO[a: %.1f, b: %.1f, c: %.1f]", a, b, a+b);
}
%.1f means a float with one digit precision after the dot separator. The code [...]
Java Font List
5 January, 2010 - 6:10 pm
Tags: AWT, fonts, Java, JVM, Larabie, Larabie Fonts, programming
Posted in english | Comments Off
Here’s a program that lists fonts available in your JVM. You can also set the environment variable JAVA_FONTS to specify the font directory.
import java.awt.GraphicsEnvironment;
public class ListFonts {
public static void main(String args[]){
GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
for(String font:e.getAvailableFontFamilyNames()){
System.out.println(font);
}
}
}
By using pipes you can count how many fonts you have:
java ListFonts|wc -l
On my Ubuntu machine here I got 556 because [...]
Tiled TMX Map Loader for Pygame
I’m using the Tiled Map Editor for a while, I even wrote that tutorial about it. It’s a general purpose tile map editor, written in Java but now migrating to C++ with Qt, that can be easily used with my set of free pixelart tiles.
A map done with Tiled is stored in a file with [...]
Java: Accessing Private Members
14 November, 2009 - 4:27 am
Tags: Class, Douglas Adams, Field, getclass, getDeclaredField, Hack, Hacking, Java, Life, Object, Object-Oriented Programming, OOP, Reflection
Posted in english | 3 comments
Using reflection to change the accessibility of a private object field and access it at runtime.
import java.lang.reflect.Field;
class Life {
private int meaning = 42;
}
class Hack {
public static void main(String args[]){
Life life = new Life();
[...]
Jedi Name
8 November, 2009 - 5:47 pm
Tags: Java, Jedi, joke, programming, star wars
Posted in english | No comments
A simple Java class that calculates your Jedi name based on your first, last name, mother’s maiden name and the city you grew up.
/*
Jedi first name: 1st 3 letters of last name + 1st 2 letters of first name
Jedi last name: 1st 2 letters of mother’s maiden name + 1st 3 letters of [...]
Cameraman Duke
One more Duke.
Source: cameraman_duke.svg
7 anos de CEJUG
16 September, 2009 - 8:58 pm
Tags: café com tapioca, cartaz, CEJUG, evento, fa7, Física, fortaleza, Java, poster
Posted in português | 2 comments
fontes: cct-set-2009.zip
Quando: esse sábado agora, 19 de Setembro de 2009.
Onde: na Faculdade 7 de Setembro (Rua Alm. Maximiniano da Fonseca, 1395).
Preço: Gratuito.
O CEJUG está comemorando seu sétimo aniversário com um Café com Tapioca especial e imperdível com diversos palestrantes nacionais e muitos sorteios de brindes. A programação completa e as incrições podem ser feitas atráves [...]
Tomorrow Java
29 August, 2009 - 10:28 pm
Tags: CEJUG, EJB, Java, Java 7, Java EE, JavaFX, Tomorrow Java
Posted in english | 2 comments
Como prometido, palestra que eu e o Rafael Carneiro fizemos para apresentar no Café com Tapioca desse mês.
Tomorrow Java
View more documents from José Maria Silveira Neto.
Update: O Paulo Jr também fez uma cobertura do evento e da apresentação dele.
JavaFX 1.1 for Linux workaround
16 May, 2009 - 8:53 am
Tags: HuaSong Liu, jaunty jackalope, Java, JavaFX, javafx4linux, jfx, Kaesar Alnijres, netbeans, RIA, ubuntu, Weiqi Gao, workaround
Posted in english | 8 comments
Download
javafx4linux.tar.bz2 (~ 36Mb).
Installing
1) Extract the javafx4linux.tar.bz2 file. In this example I’m placing it on my Desktop. After the installing process you can remove it.
2) Open your NetBeans 6.5 and go at Tools → Plugins and go to Downloaded tab. In a plain and new NetBeans installation there will be no plugin in this tab yet.
3) [...]












