def _get_encryption_headers(key, source=False):
 if (key is None):
  return {}
 key = _to_bytes(key)
 key_hash = hashlib.sha256(key).digest()
 key_hash = base64.b64encode(key_hash).rstrip()
 key = base64.b64encode(key).rstrip()
 if source:
  prefix = 'X-Goog-Copy-Source-Encryption-'
 else:
  prefix = 'X-Goog-Encryption-'
 return {(prefix + 'Algorithm'): 'AES256', (prefix + 'Key'): _bytes_to_unicode(key), (prefix + 'Key-Sha256'): _bytes_to_unicode(key_hash)}

def _get_encryption_headers ( key , source = False ) : if ( key is None ) : return { } key = _to_bytes ( key ) key_hash = hashlib . sha256 ( key ) . digest ( ) key_hash = base64 . b64encode ( key_hash ) . rstrip ( ) key = base64 . b64encode ( key ) . rstrip ( ) if source : prefix = 'X-Goog-Copy-Source-Encryption-' else : prefix = 'X-Goog-Encryption-' return { ( prefix + 'Algorithm' ) : 'AES256' , ( prefix + 'Key' ) : _bytes_to_unicode ( key ) , ( prefix + 'Key-Sha256' ) : _bytes_to_unicode ( key_hash ) }
builds customer encryption key headers :type key: bytes .