def is_base64_encoded(sample):
'''
Check if a sample is likely base64-encoded
sample - (string) The sample to evaluate
'''
base64chars = string.letters + string.digits + string.whitespace
base64chars += '/+='
# Turns out a lot of crazy things will b64-decode happily with
# sample.decode('base64'). This is the fix.
if any([char not in base64chars for char in sample]):
return False
try:
sample.decode('base64')
return True
except:
return False
评论列表
文章目录