This file contains hidden or 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
| ''' | |
| Key wrapping and unwrapping as defined in RFC 3394. | |
| Also a padding mechanism that was used in openssl at one time. | |
| The purpose of this algorithm is to encrypt a key multiple times to add an extra layer of security. | |
| Personally, I wouldn't recommend using this for most applications. | |
| Just use AES/mode CTR to encrypt your keys, the same as you would any other data. | |
| The time to use this code is when you need compatibility with another system that implements the RFC. | |
| (For example, these functions are compatible with the openssl functions of the same name.) |
This file contains hidden or 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
| ''' | |
| Implementations of some basic elliptic curve cryptography primitivese. | |
| Behavior specified by SECG in SEC1 version 1 and 2. | |
| Also ANSI X9.63. | |
| Curves specified from SEC2 version 1 and 2, | |
| and NIST "Recommended Elliptic Curves for Federal Government Use". | |
| See: http://en.wikipedia.org/wiki/Elliptic_curve_cryptography and |
This file contains hidden or 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
| $ tar cf - directory | ssh username@host tar xf - -C /tmp/ |
This file contains hidden or 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
| >>> class A(type): | |
| ... @property | |
| ... def a(cls): return 4 | |
| ... | |
| >>> class B1(object): | |
| ... __metaclass__ = A | |
| ... a = 3 | |
| ... | |
| >>> B1.a | |
| 4 |
This file contains hidden or 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
| from bisect import bisect_left, insort | |
| from itertools import ifilter | |
| #maintain invariant that dead items are only in the middle? | |
| class IndexedSet(object): | |
| def __init__(self, other=None): | |
| self.item_index_map = dict() | |
| self.item_list = [] | |
| self.dead_indices = [] | |
| if other: |
This file contains hidden or 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
| from itertools import repeat | |
| class Tree(object): | |
| def __init__(self): | |
| self.tree = [] | |
| self.balance = bytearray('') | |
| def insert(self, item): | |
| i = self._get_index(item) | |
| if i >= len(self.tree): |
This file contains hidden or 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
| class Tree(object): | |
| #0 = item | |
| #1 = left | |
| #2 = right | |
| #3 = height | |
| def __init__(self): | |
| self.root = None |
This file contains hidden or 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
| ''' | |
| JKS file format decoder. | |
| Use in conjunction with PyOpenSSL to translate to PEM, or load private key and certs | |
| directly into openssl structs and wrap sockets. | |
| See http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/security/provider/JavaKeyStore.java#JavaKeyStore.engineLoad%28java.io.InputStream%2Cchar%5B%5D%29 | |
| ''' | |
| import struct | |
| import hashlib |
This file contains hidden or 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
| import gevent | |
| import hashlib | |
| import os | |
| import line_profiler | |
| profiler = line_profiler.LineProfiler() | |
| @profiler |