質問

私はちょうど私のUbuntuシステムにpymeをインストールしました。それは簡単だった(おかげで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

私はこのようなオブジェクトを作成する方法を知りません。

役に立ちましたか?

解決

あなたはpymeドキュメントからの例に従うと、それを少し変更することができます:

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()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top