0

pymeubuntuシステムにインストールしました。簡単でした (apt-get に感謝)。サンプル コードを再現できます (キーリングの公開鍵を使用して暗号化)。今、いくつかのデータに署名したいと思いますが、サンプルコードや多くのドキュメントを見つけることができませんでした.

これは私がやっていることです:

>>> plain = pyme.core.Data('this is just some sample text\n')
>>> cipher = pyme.core.Data()
>>> c = pyme.core.Context()
>>> c.set_armor(1)
>>> name='me@office.com'
>>> c.op_keylist_start(name, 0)
>>> r = c.op_keylist_next()
>>> c.op_sign(???)

パラメータとして何を与えるべきかわからない、op_signメソッドが教えてくれる

>>> 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

しかし、そのようなオブジェクトを作成する方法がわかりません。

4

1 に答える 1

0

pyme doc の例に従って、少し変更できます。

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 = 'me@office.com'
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()
于 2009-10-07T11:56:06.870 に答える