Showing posts from April, 2012

Dart Crypto early access

The Dart project just saw its first crypto libraries land , specifically for SHA1 and SHA256. Also appearing is HMAC support. Learn how to use these very new libraries in this post. This new functionality is very new. You'll need to pull the latest from the bleeding_edge branch, as of 2012-04-30. It's so new, it's not even wired into the dart: library scheme, nor is it in the SDK yet. I expect crypto libs to get the full SDK treatment very soon. Here's an example of how to create a SHA256 hash and convert to a hex string: #import('../dart/lib/crypto/crypto.dart'); // Want this in the crypto lib? Star this bug: String digestToString(List<int> digest) {   var buf = new StringBuffer();   for (var part in digest) {     buf.add("${(part < 16) ? "0" : ""}${part.toRadixString(16).toLowerCase()}");   }   return buf.toString(); } main() {   var sha = new SHA256()

Dart Server supports Web Sockets

[EDIT: Updated on 2013-12-05] Dart is a structured web programming language that runs on the client and the server. Web sockets are bi-directional data channels for real-time streaming communication between modern web browsers and servers. Thanks to a recent commit , Dart Servers can host Web Socket connections now! You'll need a copy of the Dart SDK as of 2013-03-05 for this to work. Dart already ships with basic HttpServer functionality. The new Web Socket is built on top of HttpServer, so it slides right into an existing Dart server app. The following code snippet is a simple example of a Web Socket echo server running in Dart. import 'dart:io'; void main() { HttpServer.bind('', port) .then((HttpServer server) { print('listening for connections on $port'); server.listen((HttpRequest request) { if (request.uri.path == '/ws') { WebSocketTransformer.upgrade(request).then((WebSocket w