A taste of working with the OpenMocha Console...
makeDigestEncoder = function(kind) {
return function(str) {
if (methodOf(this)) str = this;
var algorithm = java.security.MessageDigest.getInstance(kind);
var digest = algorithm.digest(new java.lang.String(str).getBytes());
var hexdigest = '';
for (var i = 0; i < digest.length; i++) {
var b = digest[i] & 0xff;
if (b < 0x10) hexdigest += "0";
hexdigest += java.lang.Integer.toHexString(b);
}
return hexdigest;
}
}
makeDigestEncoder('SHA-512')('hello world');
If you dig this screenshot, you'll get a glimpse of OpenMocha under the hood. If you have not discovered the OpenMocha Console yet then this might inspire you to
explore it
.
04.09.2005, 11:59