views:

164

answers:

1

I just installed pyme on my ubuntu system. it was easy (thanks apt-get) and I can reproduce the example code (encrypting using a public key in my keyring). now I would like to sign some data and I didn't manage to find any example code nor much documentation.

this is what I've been doing:

>>> plain = pyme.core.Data('this is just some sample text\n')
>>> cipher = pyme.core.Data()
>>> c = pyme.core.Context()
>>> c.set_armor(1)
>>> name='[email protected]'
>>> c.op_keylist_start(name, 0)
>>> r = c.op_keylist_next()
>>> c.op_sign(???)

I don't know what to give as parameters, the op_sign method tells me

>>> help(c.op_sign)
Help on function _funcwrap in module pyme.util:

_funcwrap(*args, **kwargs)
    gpgme_op_sign(ctx, plain, sig, mode) -> gpgme_error_t

but I do not know how to create such objects.

A: 

You can follow example from pyme doc and modify it a bit:

import pyme.core
import pyme.pygpgme

plaintext = pyme.core.Data('this is a test message')
ciphertext = pyme.core.Data()
ctx = pyme.core.Context()
ctx.set_armor(1)
name = '[email protected]'
ctx.op_keylist_start(name, 0)
key = ctx.op_keylist_next()
# first argument is message to sign, second argument is buffer where to write
# the signature, third argument is signing mode, see
# http://www.gnupg.org/documentation/manuals/gpgme/Creating-a-Signature.html#Creating-a-Signature for more details.
ctx.op_sign(plaintext, ciphertext, pyme.pygpgme.GPGME_SIG_MODE_CLEAR)
ciphertext.seek(0, 0)
print ciphertext.read()
abbot
hi, thanks... but where did you find this in pyme documentation?
mariotomo
@mariotomo, there is a simple quick start program in pyme documentation. Just import pyme and help(pyme).
abbot
import pyme; help(pyme): but '''obviously''' that's the first thing I did :). on my two systems (Debian unstable and ubuntu 9.04) there's no op_sign in the text I get. did you use a different one?
mariotomo
@mariotomo, I've just tried the pyme-0.8.1.tar.gz from SourceForge; import pyme ; help(pyme) from interactive python prompt shows the documentation. I don't know what's wrong (if anything) with Debian package.
abbot