Python Crypto.Cipher.Blowfish.block_size() Examples
The following are 3
code examples of Crypto.Cipher.Blowfish.block_size().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Crypto.Cipher.Blowfish
, or try the search function
.
Example #1
Source File: security.py From kansha with BSD 3-Clause "New" or "Revised" License | 6 votes |
def cookie_encode(self, *ids): cookie = super(Authentication, self).cookie_encode(*ids) bs = Blowfish.block_size iv = Random.new().read(bs) cipher = Blowfish.new(self.KEY, Blowfish.MODE_CBC, iv) # pad cookie to block size. # Cookie is ascii base64 + ':', so we can safely pad with '@'. missing_bytes = bs - (len(cookie) % bs) cookie += '@' * missing_bytes return '%s:%s' % ( b64encode(iv), b64encode(cipher.encrypt(cookie)) ) return cookie
Example #2
Source File: encrypt.py From GloboNetworkAPI with Apache License 2.0 | 5 votes |
def encrypt_key(text, salt_key): try: bs = Blowfish.block_size extra_bytes = len(text) % bs padding_size = bs - extra_bytes padding = chr(padding_size) * padding_size padded_text = text + padding crypt_obj = Blowfish.new(salt_key, Blowfish.MODE_ECB) cipher = crypt_obj.encrypt(padded_text) return cipher except Exception as ERROR: log.error(ERROR)
Example #3
Source File: encrypt.py From GloboNetworkAPI with Apache License 2.0 | 5 votes |
def generate_key(): try: bs = Blowfish.block_size return get_random_bytes(bs) except Exception as ERROR: log.error(ERROR)