将字母表映射到字母表而不重叠的数字方式是什么?

时间:2017-03-26 14:28:10

标签: encryption

我想制作带字母到字母表的映射表。我们无法使用相同的字母值和密钥。

例如,我们可以使用密钥A - 值C,密钥B - 密钥D.但是我们不能使用密钥A - 值A,密钥C - 值C.在这种情况下,数量是多少我们可以制作映射表吗?

1 个答案:

答案 0 :(得分:0)

148,362,637,348,470,135,821,287,825。

  

在组合数学中,derangement是一组元素的排列,因此没有元素出现在其原始位置。换句话说,紊乱是一种没有固定点的排列。   -Wikipedia

假设你只使用了26次替换(例如大写字母),问题可以归结为“一组26个项目的紊乱次数是多少?”;这是import json import pandas as pd # Source Data string json_raw = '''{"Loc":"TDM","Topic":"location","LocMac":"location/fe:7a:xx:xx:xx:xx","seq":"296083773","timestamp":1488986751,"op":"OP_UPDATE","topicSeq":"46478211","sourceId":"AFBWmHSe","location":{"staEthMac":{"addr":"/xxxxx"},"staLocationX":1643.8915,"staLocationY":571.04205,"errorLevel":1076,"associated":0,"campusId":"n5THo6IINuOSVZ/cTidNVA==","buildingId":"7hY/xx==","floorId":"xxxxxxxxxx+BYoo0A==","hashedStaEthMac":"xxxx/pMVyK4Gu9qG6w=","locAlgorithm":"ALGORITHM_ESTIMATION","unit":"FEET"},"EventProcessedUtcTime":"2017-03-08T15:35:02.3847947Z","PartitionId":3,"EventEnqueuedUtcTime":"2017-03-08T15:35:03.7510000Z","IoTHub":{"MessageId":null,"CorrelationId":null,"ConnectionDeviceId":"xxxxx","ConnectionDeviceGenerationId":"636243184116591838","EnqueuedTime":"0001-01-01T00:00:00.0000000","StreamId":null}}''' # Load source data string to a Python dict json_data = json.loads(json_raw) # The key method `flattern` for converting `dict` to `2D-list` def flattern(data, key): keys = [] values = [] if key is None: for key in data: if type(data[key]) is dict: keys.extend(flattern(data[key], key)[0]) values.extend(flattern(data[key], key)[1]) else: keys.append(key) values.append(data[key]) else: for subkey in data: if type(data[subkey]) is dict: keys.extend(flattern(data[subkey], key+"."+subkey)[0]) values.extend(flattern(data[subkey], subkey)[1]) else: keys.append(key+"."+subkey) values.append(data[subkey]) return [keys, values] list2D = flattern(json_data, None) df = pd.DataFrame([list2D[1],], columns=list2D[0]) # If you want to extract the items `Loc` & `Topic` & others like `location.staEthMac.addr`, you just need to create a list for them. selected = ["Loc", "Topic"] # Use `selected` list to select the columns you want. result = df.ix[:,selected] # Transform DataFrame to csv string csv_raw = "\n".join([",".join(lst) for lst in pd.np.array(result)]) ,总密钥空间减少了约63%(26!== 1.48e26)。

对于较大的值,它大约等于4.03e26(e是大约等于2.71828的数字)。