Last active
August 29, 2015 14:22
-
-
Save kpcyrd/1ec95f93b1b13f6af35c to your computer and use it in GitHub Desktop.
crypto_yolo_verify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ | |
$ aptitude show libsodium13 | |
Package: libsodium13 | |
New: yes | |
State: installed | |
Automatically installed: no | |
Multi-Arch: same | |
Version: 1.0.1-1 | |
Priority: optional | |
Section: universe/libs | |
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> | |
Architecture: amd64 | |
Uncompressed Size: 393 k | |
Depends: libc6 (>= 2.14) | |
PreDepends: multiarch-support | |
Breaks: libsodium13 (!= 1.0.1-1) | |
Replaces: libsodium13 (< 1.0.1-1) | |
Description: Network communication, cryptography and signaturing library | |
NaCl (pronounced "salt") is a new easy-to-use high-speed software library for network communication, encryption, decryption, signatures, | |
etc. | |
NaCl's goal is to provide all of the core operations needed to build higher-level cryptographic tools. | |
Sodium is a portable, cross-compilable, installable, packageable fork of NaCl, with a compatible API. | |
Homepage: http://www.libsodium.org/ | |
$ | |
$ | |
$ python | |
Python 2.7.9 (default, Apr 2 2015, 15:33:21) | |
[GCC 4.9.2] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import libnacl | |
>>> | |
>>> libnacl.__version__ | |
'1.4.2' | |
>>> | |
>>> from libnacl import crypto_auth, crypto_auth_verify, crypto_onetimeauth, crypto_onetimeauth_verify | |
>>> | |
>>> | |
>>> | |
>>> for auth, verify in [[crypto_auth, crypto_auth_verify], [crypto_onetimeauth, crypto_onetimeauth_verify]]: | |
... print((auth, verify)) | |
... print('should be valid:') | |
... try: | |
... print(repr(verify(auth('foo', 'bar'), 'foo', 'bar'))) | |
... except: | |
... print('> invalid') | |
... print('should be invalid:') | |
... try: | |
... print(repr(verify(auth('foo', 'bar'), 'fizz', 'buzz'))) | |
... except: | |
... print('> invalid') | |
... | |
(<function crypto_auth at 0x7f799b2e10c8>, <function crypto_auth_verify at 0x7f799b2e1140>) | |
should be valid: | |
'foo' | |
should be invalid: | |
> invalid | |
(<function crypto_onetimeauth at 0x7f799b2e11b8>, <function crypto_onetimeauth_verify at 0x7f799b2e1230>) | |
should be valid: | |
'foo' | |
should be invalid: | |
'fizz' | |
>>> | |
>>> | |
>>> | |
>>> crypto_onetimeauth('foo', 'bar') | |
'\x0cKJa\x1d_\x02\x05\x0f\x15\x8a\xf4\xb7\x00\x00\x00' | |
>>> | |
>>> crypto_onetimeauth('fizz', 'buzz') | |
'\x11\xf7\xa3\x0b?n\xb7\xcb\xa4\xcc<\x10-X\x94\xea' | |
>>> | |
>>> | |
>>> | |
>>> crypto_onetimeauth_verify(crypto_onetimeauth('pubkey', 'secret'), 'pubkey', 'secret') | |
'pubkey' | |
>>> | |
>>> crypto_onetimeauth_verify(crypto_onetimeauth('pubkey', 'forged'), 'pubkey', 'secret') | |
'pubkey' | |
>>> | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment