📄 dhash.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' dHASH v1 (Dynamic HASH)
' Created by: David Midkiff (davmid@email.com)
Private Sub HelpComments()
' dHASH v1 (Dynamic HASH)
' Created by: David Midkiff (davmid@email.com)
'
' strText = Password or text to HASH
' numLength = Fixed length of HASH string size
' strKey = Programmers HASH key
' numLoop = Number of times to loop through algorithm
' numMod = MOD value
'
' numWhich: By selecting "0" as numWhich the algorithm
' will pick a random number between 1 and 9 and will add
' characters to strText based on the random number to
' create a polymorphic output.
'
' Do not select any number between 1 and 9 for numWhich
' unless you want a static output. By using "0" a single
' password can have 9 different HASH outputs. The function
' Compare will do the work for you in comparing two HASH
' strings. My recommendation is to set numWhich to 0 at all
' times.
'
' strKey is a special programmers key that is added to strText
' to allow more security. To replicate the HASH and attempt
' a brute force attack a cracker would have to generate every
' strKey to a single strText making it utterly impossible to
' even attempt brute force. strKey also works to create a
' dynamic HASH in which different programs using the HASH can
' create totally different algorithms all-together separating
' itself from other programs. This way other programs won't
' be able to work with another program's HASH without the
' programmer's key.
'
' numLength allows the programmer to specify the HASH string
' size. The maximum size is 100 characters and the minimum size
' is 8 character. Less than 8 characters would create a
' controversy by letting two different passwords create the
' same HASH output in some cases.
'
' numLoop is just a basic looping function which will loop
' through the math operators a set amount of times which
' generates different HASH outputs altogether.
'
' numMod is also pretty basic. All the math operators are
' set to a certain MOD value. You have the power to specify
' this MOD value which in-turn allows more dynamic HASH output.
' If you don't understand MOD then just set the value to 0
' and the algorithm will set the value to the default: 1048576.
'
' Example: a$ = Hash("password", 100, "key", 5, 1048576, 0)
' MsgBox Compare(a$, "password", "key", 5, 1048576)
'
' Compare takes a HASH string and calculates the length
' and then finds the numWhich value in the HASH string. Taking
' these values it recreates the HASH using the values you passed
' to it (strText, strKey, numLoop, numMod) and the values it
' calculated. It then does a check to see if the strHASH
' matches the recreated HASH. If it does then it returns a
' Boolean value of True. If it doesn't match it returns a
' Boolean value of False. The Compare function saves you
' the extra coding and allows quick HASH matching for your
' password protection schemes.
'
' All of these functions work together to create a very dynamic
' HASH algorithm. Instead of static HASH output you could have
' an infinite amount of different HASH outputs for a single password.
' This works great with password protection schemes that save
' passwords in the registry or in a file. It also can be used
' in a text cipher algorithm.
End Sub
Public Function Compare(strHASH As String, strText As String, strKey As String, numLoop As Integer, numMod As Long) As Boolean
' Read HelpComments for explanation.
Temp$ = Right$(strHASH, 1)
If Temp$ = "1" Or Temp$ = "2" Or Temp$ = "3" Or Temp$ = "4" Or Temp$ = "5" Or Temp$ = "6" Or Temp$ = "7" Or Temp$ = "8" Or Temp$ = "9" Then
cHash$ = Hash(strText, Len(strHASH), strKey, numLoop, numMod, CStr(Temp$))
If strHASH = cHash$ Then
Compare = True
Exit Function
Else
Compare = False
Exit Function
End If
Else
Compare = False
Exit Function
End If
End Function
Public Function Hash(strText As String, numLength As Integer, strKey As String, numLoop As Integer, numMod As Long, numWhich As Integer)
' Read HelpComments for explanation.
Dim A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y
If numLength < 8 Or numLength > 100 Then
MsgBox "Maximum length: 100" + Chr$(10) + "Minimum length: 8", vbCritical + vbOKOnly, "dHASH"
Exit Function
Else
numLength = numLength - 1
End If
If numWhich > 9 Or numWhich < 0 Then
MsgBox "Maximum which: 9" + Chr$(10) + "Minimum which: 0", vbExclamation + vbOKOnly, "dHASH"
Exit Function
End If
strText = strKey + strText + strKey
If numWhich = 0 Then
Randomize Timer
numWhich = Int(Rnd * 9) + 1
End If
If numWhich = 1 Then strText = "afkjd" + strText + "fWWsnfi!"
If numWhich = 2 Then strText = "afjhv" + strText + "hacknotm"
If numWhich = 3 Then strText = "lPmfZ" + strText + "dOnotTry"
If numWhich = 4 Then strText = "crPPz" + strText + "wOOfaksx"
If numWhich = 5 Then strText = "aisur" + strText + "fa9#RF31"
If numWhich = 6 Then strText = "david" + strText + "FKGmsoa#"
If numWhich = 7 Then strText = "gjsaw" + strText + "12563357"
If numWhich = 8 Then strText = "gaoXz" + strText + "rAmmStlz"
If numWhich = 9 Then strText = "raTTf" + strText + "kOntonNo"
If numMod = 0 Then numMod = 1048576
For yLoop = 1 To numLoop
For zLoop = 1 To Len(strText)
A = A + Asc(Mid$(strText, zLoop, 1))
B = B + Asc(Mid$(strText, zLoop, 1))
C = C + Asc(Mid$(strText, zLoop, 1))
D = D + Asc(Mid$(strText, zLoop, 1))
E = E + Asc(Mid$(strText, zLoop, 1))
F = F + Asc(Mid$(strText, zLoop, 1))
G = G + Asc(Mid$(strText, zLoop, 1))
H = H + Asc(Mid$(strText, zLoop, 1))
I = I + Asc(Mid$(strText, zLoop, 1))
J = J + Asc(Mid$(strText, zLoop, 1))
K = K + Asc(Mid$(strText, zLoop, 1))
L = L + Asc(Mid$(strText, zLoop, 1))
M = M + Asc(Mid$(strText, zLoop, 1))
N = N + Asc(Mid$(strText, zLoop, 1))
O = O + Asc(Mid$(strText, zLoop, 1))
P = P + Asc(Mid$(strText, zLoop, 1))
Q = Q + Asc(Mid$(strText, zLoop, 1))
R = R + Asc(Mid$(strText, zLoop, 1))
S = S + Asc(Mid$(strText, zLoop, 1))
T = T + Asc(Mid$(strText, zLoop, 1))
U = U + Asc(Mid$(strText, zLoop, 1))
V = V + Asc(Mid$(strText, zLoop, 1))
W = W + Asc(Mid$(strText, zLoop, 1))
X = X + Asc(Mid$(strText, zLoop, 1))
Y = Y + Asc(Mid$(strText, zLoop, 1))
A = (A * 717 + 717) Mod numMod
B = (B * 797 + 797) Mod numMod
C = (C * 817 + 817) Mod numMod
D = (D * 897 + 897) Mod numMod
E = (E * 917 + 917) Mod numMod
F = (F * 997 + 997) Mod numMod
G = (G * 1017 + 1017) Mod numMod
H = (H * 1097 + 1097) Mod numMod
I = (I * 1117 + 1117) Mod numMod
J = (J * 1197 + 1197) Mod numMod
K = (K * 1217 + 1217) Mod numMod
L = (L * 1297 + 1297) Mod numMod
M = (M * 1317 + 1317) Mod numMod
N = (N * 1397 + 1397) Mod numMod
O = (O * 1417 + 1417) Mod numMod
P = (P * 1497 + 1497) Mod numMod
Q = (Q * 1517 + 1517) Mod numMod
R = (R * 1597 + 1597) Mod numMod
S = (S * 1617 + 1617) Mod numMod
T = (T * 1697 + 1697) Mod numMod
U = (U * 1717 + 1717) Mod numMod
V = (V * 1111 + 1111) Mod numMod
W = (W * 1222 + 1222) Mod numMod
X = (X * 1333 + 1333) Mod numMod
Y = (Y * 1444 + 1444) Mod numMod
Next zLoop
For zLoop = 1 To 7
A = (A * 197 + 997) Mod numMod
B = (B * 297 + 897) Mod numMod
C = (C * 397 + 797) Mod numMod
D = (D * 497 + 697) Mod numMod
E = (E * 597 + 597) Mod numMod
F = (F * 697 + 497) Mod numMod
G = (G * 797 + 397) Mod numMod
H = (H * 897 + 297) Mod numMod
I = (I * 997 + 197) Mod numMod
J = (J * 197 + 997) Mod numMod
K = (K * 297 + 897) Mod numMod
L = (L * 397 + 797) Mod numMod
M = (M * 497 + 697) Mod numMod
N = (N * 597 + 597) Mod numMod
O = (O * 697 + 497) Mod numMod
P = (P * 797 + 397) Mod numMod
Q = (Q * 897 + 297) Mod numMod
R = (R * 997 + 197) Mod numMod
S = (S * 197 + 997) Mod numMod
T = (T * 297 + 897) Mod numMod
U = (U * 397 + 797) Mod numMod
V = (V * 497 + 697) Mod numMod
W = (W * 597 + 597) Mod numMod
X = (X * 697 + 497) Mod numMod
Y = (Y * 797 + 397) Mod numMod
Next zLoop
Next yLoop
tHash$ = Right$("0000" & Hex$(A), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(B), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(C), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(D), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(E), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(F), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(G), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(H), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(I), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(J), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(K), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(L), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(M), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(N), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(O), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(P), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(Q), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(R), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(S), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(T), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(U), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(V), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(W), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(X), 4)
tHash$ = tHash$ + Right$("0000" & Hex$(Y), 4)
Hash = Left$(tHash$, numLength) + CStr(numWhich)
End Function
Public Sub About()
MsgBox "dHASH v1 (Dynamic HASH)" + Chr$(10) + Chr$(10) + "Created by: David Midkiff (davmid@email.com)", vbOKOnly, "About"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -