Aruisdante's answer is very good, I just wanted to expand on the answer if you have to use a Python previous to 3.4, as there does exist a backport on PyPI:
from enum import IntEnum
class Crypt(IntEnum):
none = 0
unknown = 1
wep = (1 << 1)
layer3 = (1 << 2)
# Derived from WPA headers
wep40 = (1 << 3)
wep104 = (1 << 4)
tkip = (1 << 5)
wpa = (1 << 6)
psk = (1 << 7)
aes_ocb = (1 << 8)
aes_ccm = (1 << 9)
# WPA Migration Mode
wpa_migmode = (1 << 19)
# Derived from data traffic
leap = (1 << 10)
ttls = (1 << 11)
tls = (1 << 12)
peap = (1 << 13)
isakmp = (1 << 14)
pptp = (1 << 15)
fortress = (1 << 16)
keyguard = (1 << 17)
unknown_nonwep = (1 << 18)
@classmethod
def find_crypts(cls, magic_number):
crypts = []
for mask in cls:
if magic_number & mask == mask:
crypts.append(mask)
if len(crypts) > 1:
# remove false positive of none
crypts = crypts[1:]
return crypts
print Crypt.find_crypts(0)
[<Crypt.none: 0>]
print Crypt.find_crypts(706)
[<Crypt.wep: 2>, <Crypt.wpa: 64>, <Crypt.psk: 128>, <Crypt.aes_ccm: 512>]