Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8bab94d

Browse files
committed
added two new functions: isBase64EncodedString and isHexEncodedString for Feature #71
1 parent 5a6a01f commit 8bab94d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lib/core/common.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,8 @@ def safeStringFormat(formatStr, params):
913913

914914
return retVal
915915

916-
def sanitizeAsciiString(string):
917-
return "".join(char if ord(char) < 128 else '?' for char in string)
916+
def sanitizeAsciiString(subject):
917+
return "".join(char if ord(char) < 128 else '?' for char in subject)
918918

919919
def decloakToNamedTemporaryFile(filepath, name=None):
920920
retVal = NamedTemporaryFile()
@@ -952,3 +952,9 @@ def posixToNtSlashes(filepath):
952952

953953
def ntToPosixSlashes(filepath):
954954
return filepath.replace('\\', '/')
955+
956+
def isBase64EncodedString(subject):
957+
return re.match(r"\A(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\Z", subject) is not None
958+
959+
def isHexEncodedString(subject):
960+
return re.match(r"\A[0-9a-fA-F]+\Z", subject) is not None

0 commit comments

Comments
 (0)