def crypto_box(msg, nonce, pk, sk):
_assert_len('nonce', nonce, crypto_box_NONCEBYTES)
_assert_len('pk', pk, crypto_box_PUBLICKEYBYTES)
_assert_len('sk', sk, crypto_box_SECRETKEYBYTES)
c = bytearray(crypto_box_MACBYTES + len(msg))
_raise_on_error(
lib.crypto_box_easy(
ffi.cast("unsigned char *", ffi.from_buffer(c)),
msg,
len(msg),
nonce,
pk,
sk,
),
)
return binary_type(c)
评论列表
文章目录