MCPcopy Index your code
hub / github.com/RNCryptor/RNCryptor-python / encrypt

Method encrypt

rncryptor.py:134–154  ·  view source on GitHub ↗

Encrypt `data` using `password`.

(self, data, password)

Source from the content-addressed store, hash-verified

132 return data
133
134 def encrypt(self, data, password):
135 """Encrypt `data` using `password`."""
136 data = self.pre_encrypt_data(data)
137 password = to_bytes(password)
138
139 encryption_salt = self.encryption_salt
140 encryption_key = self._pbkdf2(password, encryption_salt)
141
142 hmac_salt = self.hmac_salt
143 hmac_key = self._pbkdf2(password, hmac_salt)
144
145 iv = self.iv
146 cipher_text = self._aes_encrypt(encryption_key, iv, data)
147
148 version = b'\x03'
149 options = b'\x01'
150
151 new_data = b''.join([version, options, encryption_salt, hmac_salt, iv, cipher_text])
152 encrypted_data = new_data + self._hmac(hmac_key, new_data)
153
154 return self.post_encrypt_data(encrypted_data)
155
156 @property
157 def encryption_salt(self):

Calls 6

pre_encrypt_dataMethod · 0.95
_pbkdf2Method · 0.95
_aes_encryptMethod · 0.95
_hmacMethod · 0.95
post_encrypt_dataMethod · 0.95
to_bytesFunction · 0.85