From 41ba9216267b1fd7c87c4fffc153b29742d9a916 Mon Sep 17 00:00:00 2001 From: antius Date: Fri, 2 May 2014 18:47:50 +0200 Subject: [PATCH] Simplify and optimize --- src/helper_generic.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/helper_generic.py b/src/helper_generic.py index 2ea088cc..f3380b26 100644 --- a/src/helper_generic.py +++ b/src/helper_generic.py @@ -33,10 +33,5 @@ def isHostInPrivateIPRange(host): return True return False -def addDataPadding(data, desiredMsgLength = 12): - if len(data) >= desiredMsgLength: - return data - padded = data - while len(padded) < desiredMsgLength: - padded += '\x00' - return padded +def addDataPadding(data, desiredMsgLength = 12, paddingChar = '\x00'): + return data + paddingChar * (desiredMsgLength - len(data))