Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2016-09-17 16:59:43 +0200
committerArthur de Jong <arthur@arthurdejong.org>2016-09-24 15:20:52 +0200
commitb1f8f870c9f751d7910e18d929f3753c521c654c (patch)
tree54b049c4f673927e97d6abfa2f83f1ee43066bf8
parente23a4674c960f09af8cac28f3cbe876f2bc496fc (diff)
Add writing example to toplevel documentation
-rw-r--r--.gitignore1
-rw-r--r--README11
-rw-r--r--pskc/__init__.py9
3 files changed, 20 insertions, 1 deletions
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.
"""