Skip to content

Instantly share code, notes, and snippets.

View avilches's full-sized avatar

Alberto Vilches avilches

  • Madrid, Spain
View GitHub Profile
@avilches
avilches / Sha.java
Created December 21, 2010 16:25
How to encode a hex SHA256 in Java
import java.security.*;
public class Sha {
public static String hash256(String data) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(data.getBytes());
return bytesToHex(md.digest());
}
public static String bytesToHex(byte[] bytes) {
StringBuffer result = new StringBuffer();
for (byte byt : bytes) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
{"id":147,
"last_updated":1290507216000,
"date_created":1290507215000,
"created_by":"you",
"user_id":8,
"name":"Test",
"gender":"male",
"title":"Title",
"business":"Paradigma",
@avilches
avilches / create_contact_json
Created November 24, 2010 08:32
JSON to create a contact
{"contact":{
"user_id":8,
"name":"Test",
"gender":"male",
"title":"Title",
"business":"Paradigma",
"data":[
{"type":"telephone","value":"+15717483198", "rel":"work","is_primary":true},
{"type":"email", "value":"[email protected]","label":"wow","is_primary":false}
],
@avilches
avilches / feed_contacts_ok
Created November 24, 2010 08:27
Feed contacts JSON Response
{"updated":[130,131,132,133],
"deleted":[1,2,4],
"timestamp":1290506001724 }