'>>> g = GnuPG(None)
>>> g.sign("Hello, World", fromkey="smari@mailpile.is")[0]
0'

def sign(self, data, fromkey=None, armor=True, detatch=True, clearsign=False, passphrase=None):

    if (passphrase is not None):
        self.passphrase = passphrase.get_reader()
    if (fromkey and (passphrase is None)):
        self.prepare_passphrase(fromkey, signing=True)
    if (detatch and (not clearsign)):
        action = ['--detach-sign']
    elif clearsign:
        action = ['--clearsign']
    else:
        action = ['--sign']
    if armor:
        action.append('--armor')
    if fromkey:
        action.append('--local-user')
        action.append(fromkey)
    self.event.running_gpg((_('Signing    %d    bytes    of    data    with    %s') % (len(data), (fromkey or _('default')))))
    retvals = self.run(action, gpg_input=data, send_passphrase=True)
    self.passphrase = None
    return (retvals[0], ''.join(retvals[1]['stdout']))
