   sign: (data, callback) ->
     @create_crypt (crypt) ->
       crypt.sign data, (_, signed) ->
-        callback(signed.signature)
+        callback(zc.pad_base64(signed.signature))
 
   verify: (data, signature, callback) ->
     @create_crypt (crypt) ->

zc.format_pem = (key, title) ->
  rv = "-----BEGIN " + title + "-----\n"
  while key.length % 4 != 0
    key = key + '='
  while key
    rv += key.slice(0, 64) + "\n"
    key = key.slice(64)

  k = new RSAKey()
  k.generate(size, '10001')
  key = k.privateKeyToPkcs1PemString()
  _.defer(callback, zc.format_pem(zc.pad_base64(key), "RSA PRIVATE KEY"))


zc.get_public_key = (private_key) ->
  key = new RSAKey()
  key.readPrivateKeyFromPEMString(private_key)
  public_key = key.publicKeyToX509PemString()
  return zc.format_pem(zc.pad_base64(public_key), "PUBLIC KEY")


class zc.Crypto
