Skip to content

Commit 6858e37

Browse files
committed
Handle nullable columns in Encrypted
1 parent 1ae39f2 commit 6858e37

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sqlorm-py"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
description = "A new kind or ORM that do not abstract away your database or SQL queries."
55
authors = ["Maxime Bouroumeau-Fuseau <[email protected]>"]
66
readme = "README.md"

sqlorm/types/encrypted.py

+4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ def __init__(self, key):
1313
self.key = key
1414

1515
def encrypt(self, raw):
16+
if raw is None:
17+
return None
1618
raw = self.pad(raw).encode()
1719
iv = Random.new().read(AES.block_size)
1820
key = self.key() if callable(self.key) else self.key
1921
cipher = AES.new(key, AES.MODE_CBC, iv)
2022
return base64.b64encode(iv + cipher.encrypt(raw))
2123

2224
def decrypt(self, enc):
25+
if enc is None:
26+
return None
2327
enc = base64.b64decode(enc)
2428
iv = enc[:16]
2529
key = self.key() if callable(self.key) else self.key

0 commit comments

Comments
 (0)