Friday, January 28, 2011

Java binary data process class DataInputStream

The good sample for binary data processing

Thursday, January 27, 2011

Search a byte array for a byte sequence

The Knuth-Morris-Pratt Pattern Matching Algorithm can be used to search a byte array.
http://helpdesk.objects.com.au/java/search-a-byte-array-for-a-byte-sequence

Thursday, January 20, 2011

Stanford Javascript Crypto Library

SJCL is secure. It uses the industry-standard AES algorithm at 128, 192 or 256 bits; the SHA256 hash function; the HMAC authentication code; the PBKDF2 password strengthener; and the CCM and OCB authenticated-encryption modes.

http://crypto.stanford.edu/sjcl/
https://github.com/bitwiseshiftleft/sjcl/tree/master/browserTest
http://bitwiseshiftleft.github.com/sjcl/demo/

Wednesday, January 19, 2011

BlackBerry webkit javascript touch events


var lastX=0;
var lastY=0;
document.ontouchstart = function(event) {
var touchEvent = event.changedTouches[0];
lastX = touchEvent.pageX;
lastY = touchEvent.pageY;
}

document.ontouchmove = function(event) {
event.preventDefault();
}

document.ontouchend = function(event) {
var touchEvent = event.changedTouches[0];
var deltaX = lastX - touchEvent.pageX;
var deltaY = lastY - touchEvent.pageY;
alert("deltaX: " + deltaX + " deltaY: " + deltaY);
}


For android and iPhone, it can be

startPoint.x = e.touches[0].pageX;
startPoint.y = e.touches[0].pageY;

General codes:

if(!e['touches']) e['touches'] = e.changedTouches;

startPoint.x = e.touches[0].pageX;
startPoint.y = e.touches[0].pageY;

Tuesday, January 18, 2011

blackberry security error: dom exception 18

blackberry phonegap error

security error: dom exception 18

Use the following steps to remove the database on the internal MMC.
1) Restart the device
2) Start Media application then select “Explore” in the Menu
3) Select “Show Hidden” in the Menu
4) Navigate to /Device/BlackBerry/system/appdata/rim
5) Delete the webstorage folder if there
6) Start your apps.