diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2016-09-17 16:59:43 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2016-09-24 15:20:52 +0200 |
commit | b1f8f870c9f751d7910e18d929f3753c521c654c (patch) | |
tree | 54b049c4f673927e97d6abfa2f83f1ee43066bf8 | |
parent | e23a4674c960f09af8cac28f3cbe876f2bc496fc (diff) |
Add writing example to toplevel documentation
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | README | 11 | ||||
-rw-r--r-- | pskc/__init__.py | 9 |
3 files changed, 20 insertions, 1 deletions
@@ -10,3 +10,4 @@ __pycache__ /build /coverage /dist +/output.pskcxml @@ -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. """ |