From b1f8f870c9f751d7910e18d929f3753c521c654c Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sat, 17 Sep 2016 16:59:43 +0200 Subject: Add writing example to toplevel documentation --- .gitignore | 1 + README | 11 ++++++++++- pskc/__init__.py | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4883d7f..919b186 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ __pycache__ /build /coverage /dist +/output.pskcxml diff --git a/README b/README index d52ded3..aa5956a 100644 --- a/README +++ b/README @@ -19,7 +19,7 @@ API The module provides a straightforward API that is mostly geared towards parsing existing PSKC files. -Extracting key material from encrypted PSKC files is as simple as. +Extracting key material from encrypted PSKC files is as simple as: >>> from pskc import PSKC >>> pskc = PSKC('tests/rfc6030/figure7.pskcxml') @@ -28,6 +28,15 @@ Extracting key material from encrypted PSKC files is as simple as. ... print key.serial, key.secret 987654321 12345678901234567890 +Writing am encrypted PSKC file is as simple as: + +>>> pskc = PSKC() +>>> key = pskc.add_key( +... id='456', secret='987654321', manufacturer='Manufacturer', +... algorithm = 'urn:ietf:params:xml:ns:keyprov:pskc:hotp') +>>> pskc.encryption.setup_pbkdf2('passphrase') +>>> pskc.write('output.pskcxml') + The key object has a number of properties. See the pskc.key.Key documentation for details. diff --git a/pskc/__init__.py b/pskc/__init__.py index a99a4a5..53f63ff 100644 --- a/pskc/__init__.py +++ b/pskc/__init__.py @@ -37,6 +37,15 @@ The following prints all keys, decrypting using a password: ... print('%s %s' % (key.serial, str(key.secret.decode()))) 987654321 12345678901234567890 +The following generates an encrypted PSKC file: + +>>> pskc = PSKC() +>>> key = pskc.add_key( +... id='456', secret='987654321', manufacturer='Manufacturer', +... algorithm = 'urn:ietf:params:xml:ns:keyprov:pskc:hotp') +>>> pskc.encryption.setup_pbkdf2('passphrase') +>>> pskc.write('output.pskcxml') + The module should be able to handle most common PSKC files. """ -- cgit v1.2.3