如何解决解码excel日期掩码
我需要尝试找到一种算法来解码一组 Excel 日期。
一位前员工曾告诉我,他可以在 Excel 中对日期进行编码,但没有人会弄清楚,他说“就像大海捞针”。我的回答是“为什么有人要这样做?”在他因盗窃大量数据而离开后,我找到了一组标有“记录数字”的图表,从 T20000 到 T39999。这些图表应该有伴随的出生日期,但不要 - 缺少出生日期。这些图表隐藏在我们常用的 6 到 7 位数字和纯数字图表中,而不是以“T”开头。鉴于此背景(和其他数据),我怀疑这是出于无辜的原因并怀疑欺诈,例如医疗保险或保险欺诈。 “T”后面的 5 位数字可以对生日进行编码。这些数字类似于 Excel 用来存储日期的常用 5 位数字。通过寻找其他方法来查找生日,我能够找到一些生日。几个例子是:
Record # Exel DOB (real) DOB
T30007 27369 12/6/1974
T31414 16803 1/1/1946
T31738 22156 8/28/1960
其中有 2-3 K 没有出生日期。
简单的加法或减法是找不到答案的。我怀疑他添加(或减去)然后翻转单个数字,然后再次添加(或减去)或类似的算法。像扑克中的5张牌一样改变5位数字的顺序(前员工玩了很多扑克)。
我编写了一个 Excel VBA 程序来尝试使用以下试验来评估这一点:1) 将 1 添加到 9999,2) 然后切换最后 4 位数字的顺序,然后 3) 添加或减去 1 到 9999。但是,可能性数 (9999 * 2^4 * 9999 * 2 ) 远远超过 Excel 中的行限制(不包括非匹配项)并且将其分解成更小的部分在我的非游戏计算机上仍然运行速度太慢。我不精通 C、Java 或 Python,但怀疑这些可能是更好的选择。
我运行缓慢的 Excel VBA 代码:
Sub Decode_DOB()
'The accompanying table is Sheet1 which this runs off
Dim Org(111,5) As Long
Dim BD1(111,5) As Long
Dim Var_1(111,5) As Long
Dim VarTT(111) As Long
Dim VarTT1(111) As Long
Dim VarTT2(111) As Long
Dim Save_Counter As Long
Dim icounter As Long
Dim int_Digit_Count As Integer
Save_Counter = 1 'Counter to save the spreadsheet at intervals
icounter = 2 'Counter to keep track of current row number
'Org(x,y) array to store the original chart record starting with "T"
'Org(n2,0) for the total 5 digit number,then Org(n2,1 to 5) to break out each digit
For n2 = 2 To 25
Org(n2,0) = Sheet1.Cells(n2,2).Value
Org(n2,1) = Mid(Org(n2,0),1,1)
Org(n2,2) = Mid(Org(n2,2,3) = Mid(Org(n2,3,4) = Mid(Org(n2,4,5) = Mid(Org(n2,5,1)
Next n2
'BD1(x,y) array to store the original chart record starting with "T"
'BD1(n1,then BD1(n1,1 to 5) to break out each digit
For n1 = 2 To 25
BD1(n1,0) = Sheet1.Cells(n1,28).Value
BD1(n1,1) = Mid(BD1(n1,1)
BD1(n1,2) = Mid(BD1(n1,3) = Mid(BD1(n1,4) = Mid(BD1(n1,5) = Mid(BD1(n1,1)
Next n1
'Sequentially try adding 1 to 9999
For n = 1 To 9999
For i = 2 To 25
Var_1(i,0) = Org(i,0) - n
Var_1(i,1) = Mid(Var_1(i,1)
Var_1(i,2) = Mid(Var_1(i,3) = Mid(Var_1(i,4) = Mid(Var_1(i,5) = Mid(Var_1(i,1)
'Sequentially "Flip the digits" or "Cards" only using the last 4
For k = 2 To 5
For l = 2 To 5
For m = 2 To 5
For p = 2 To 5
'Combine digits to get the total 5 digit number
VarTT(i) = Var_1(i,1) * 10000 + Var_1(i,k) * 1000 + Var_1(i,l) * 100 + Var_1(i,m) * 10 + Var_1(i,p)
'Sequentially and and subtract from the result
For ii = 1 To 9999
VarTT1(i) = VarTT(i) + ii
VarTT2(i) = VarTT(i) - ii
'Test valid "Flips" - only one of each digit allowed
'and the total 1+2+3+4+5 should = 15
int_Digit_Count = 1 + k + l + m + p
If (k = l Or k = m) Or k = p Then
int_Digit_Count = 0
End If
If l = m Or l = p Then
int_Digit_Count = 0
End If
If m = p Then
int_Digit_Count = 0
End If
'test to see if the result matches the birthdate
If VarTT1(i) = BD1(i,0) Or VarTT2(i) = BD1(i,0) Then
'and test for valid "Flip"
If int_Digit_Count = 15 Then
'If the sequence and valid flip creates a match,write to Sheet2
Sheet2.Cells(icounter,1).Value = i
Sheet2.Cells(icounter,2).Value = Org(i,0)
Sheet2.Cells(icounter,3).Value = Org(i,0) - n
Sheet2.Cells(icounter,4).Value = VarTT(i)
Sheet2.Cells(icounter,5).Value = BD1(i,6).Value = n
Sheet2.Cells(icounter,7).Value = Var_1(i,1)
Sheet2.Cells(icounter,8).Value = Var_1(i,2)
Sheet2.Cells(icounter,9).Value = Var_1(i,3)
Sheet2.Cells(icounter,10).Value = Var_1(i,4)
Sheet2.Cells(icounter,11).Value = Var_1(i,5)
Sheet2.Cells(icounter,13).Value = 1
Sheet2.Cells(icounter,14).Value = k
Sheet2.Cells(icounter,15).Value = l
Sheet2.Cells(icounter,16).Value = m
Sheet2.Cells(icounter,17).Value = p
Sheet2.Cells(icounter,19).Value = VarTT1(i)
Sheet2.Cells(icounter,20).Value = VarTT2(i)
Sheet2.Cells(icounter,21).Value = ii
FlipPattern = 1 * 10000 + k * 1000 + l * 100 + m * 10 + p
Sheet2.Cells(icounter,22).Value = FlipPattern
icounter = icounter + 1
'Save the spreadsheet every 5000 rows in case the program "blows up"
Save_Counter = Save_Counter + 1
If Save_Counter > 5000 Then
ActiveWorkbook.Save
Save_Counter = 1
Sheet2.Cells(1,12).Value = icounter
Sheet2.Cells(icounter,24).Value = Time()
Application.Wait (Now + TimeValue("00:00:01"))
End If
End If
End If
'ii for last number added or subtracted
Next ii
'p,m,l,k for flip sequences
Next p
Next m
Next l
Next k
'For each "T" number on Sheet 1
Next i
Next n
'Matches can then be sorted on n,"Flip" and ii and look for a "common denominator"
End Sub
Sub Sort_Matches()
'Run this after sorting to mark multiple matches and filter
last_row = Sheet5.Cells(Rows.count,1).End(xlUp).Row
For ijj = 2 To last_row
If Sheet5.Cells(ijj,6).Value = Sheet5.Cells(ijj - 1,6).Value Then
If Sheet5.Cells(ijj,21).Value = Sheet5.Cells(ijj - 1,21).Value Then
If Sheet5.Cells(ijj,22).Value = Sheet5.Cells(ijj - 1,22).Value Then
Sheet5.Cells(ijj - 1,23).Value = "XX"
Sheet5.Cells(ijj,23).Value = "XX"
End If
End If
End If
Next ijj
End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。