File: test_output_io.py

package info (click to toggle)
py-rnp 0.1.0%2Bgit20221014.01b7129-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 424 kB
  • sloc: python: 3,062; sh: 8; makefile: 4
file content (16 lines) | stat: -rw-r--r-- 400 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import io
import rnp


def test_output_io():
    rpgp = rnp.Rnp()
    rpgp.set_password_provider(lambda key, reason: "password")

    plaintext = b"some secret"
    bio = io.BytesIO()
    outp = rnp.Output.to_io(bio)
    assert (
        rpgp.symmetric_encrypt(rnp.Input.from_bytes(plaintext), "password", outp=outp)
        is None
    )
    assert rpgp.decrypt(bytes(bio.getbuffer())) == plaintext