我想加密一条信息…这是我生成的消息
from ctypes import memmove, addressof, Structure, c_uint16,c_bool
class AC(Structure):
_fields_ = [("UARFCN", c_uint16),
("ValidUARFCN", c_bool ),("PassiveActivationTime", c_uint16) ]
def __init__(self , UARFCN ,ValidUARFCN , PassiveActivationTime):
self.UARFCN = UARFCN
self.ValidUARFCN = True
self.PassiveActivationTime = PassiveActivationTime
def __str__(self):
s = "AC"
s += "UARFCN:" + str(self.UARFCN)
s += "ValidUARFCN" + str(self.ValidUARFCN)
s += "PassiveActivationTime" +str(self.PassiveActivationTime)
return s
class ABCD(AC):
a1 = AC( 0xADFC , True , 2)
a2 = AC( 13 , False ,5)
print a1
print a2
我想对其进行编码,然后将其存储到变量中……那么我该怎么做呢?
from hashlib import md5
和md5(String_here).hexdigest()
。 - Bogdanpack
(struct.pack
)的含义。 - agf