用python寫了個函數來加深一下理解,代碼如下:
#!/usr/bin/env python3
#coding:utf-8
#by spwpun
def xtime(hexstr):
num = int(hexstr,16)
bs1 = bin(num)[2:]
if len(bs1)!=8:
bs1 = '0'*(8-len(bs1))+bs1
num = (num<<1)%2**8
if bs1[0]=='1':
num = num^int("1B",16)
return hex(num)[2:]
print(xtime("AE"))