📄 hmacsha256.cls
字号:
Set mBase = Cor.NewHMACBase(New SHA256Managed, 64, "SHA256")
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' HMAC Interface
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Property Get HMAC_CanReuseTransform() As Boolean
HMAC_CanReuseTransform = CanReuseTransform
End Property
Private Property Get HMAC_CanTransformMultipleBlocks() As Boolean
HMAC_CanTransformMultipleBlocks = CanTransformMultipleBlocks
End Property
Private Sub HMAC_Clear()
Call Clear
End Sub
Private Function HMAC_ComputeHash(Source As Variant, Optional Index As Variant, Optional Count As Variant) As Byte()
HMAC_ComputeHash = ComputeHash(Source, Index, Count)
End Function
Private Function HMAC_Equals(Value As Variant) As Boolean
HMAC_Equals = Equals(Value)
End Function
Private Function HMAC_GetHashCode() As Long
HMAC_GetHashCode = GetHashCode
End Function
Private Property Get HMAC_Hash() As Byte()
HMAC_Hash = Hash
End Property
Private Property Let HMAC_HashName(ByVal RHS As String)
HashName = RHS
End Property
Private Property Get HMAC_HashName() As String
HMAC_HashName = HashName
End Property
Private Property Get HMAC_HashSize() As Long
HMAC_HashSize = HashSize
End Property
Private Sub HMAC_Initialize()
Call Initialize
End Sub
Private Property Get HMAC_InputBlockSize() As Long
HMAC_InputBlockSize = InputBlockSize
End Property
Private Property Let HMAC_Key(RHS() As Byte)
Call mBase.SetKey(RHS)
End Property
Private Property Get HMAC_Key() As Byte()
HMAC_Key = Key
End Property
Private Property Get HMAC_OutputBlockSize() As Long
HMAC_OutputBlockSize = OutputBlockSize
End Property
Private Function HMAC_ToString() As String
HMAC_ToString = ToString
End Function
Private Function HMAC_TransformBlock(InputBuffer() As Byte, ByVal InputOffset As Long, ByVal InputCount As Long, OutputBuffer() As Byte, ByVal OutputOffset As Long) As Long
HMAC_TransformBlock = TransformBlock(InputBuffer, InputOffset, InputCount, OutputBuffer, OutputOffset)
End Function
Private Function HMAC_TransformFinalBlock(InputBuffer() As Byte, ByVal InputOffset As Long, ByVal InputCount As Long) As Byte()
HMAC_TransformFinalBlock = TransformFinalBlock(InputBuffer, InputOffset, InputCount)
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' IObject Interface
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function IObject_Equals(Value As Variant) As Boolean
IObject_Equals = Equals(Value)
End Function
Private Function IObject_GetHashcode() As Long
IObject_GetHashcode = GetHashCode
End Function
Private Function IObject_ToString() As String
IObject_ToString = ToString
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' HashAlgorithm Interface
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Property Get HashAlgorithm_CanReuseTransform() As Boolean
HashAlgorithm_CanReuseTransform = CanReuseTransform
End Property
Private Property Get HashAlgorithm_CanTransformMultipleBlocks() As Boolean
HashAlgorithm_CanTransformMultipleBlocks = CanTransformMultipleBlocks
End Property
Private Sub HashAlgorithm_Clear()
Call Clear
End Sub
Private Function HashAlgorithm_ComputeHash(Source As Variant, Optional Index As Variant, Optional Count As Variant) As Byte()
HashAlgorithm_ComputeHash = ComputeHash(Source, Index, Count)
End Function
Private Function HashAlgorithm_Equals(Value As Variant) As Boolean
HashAlgorithm_Equals = Equals(Value)
End Function
Private Function HashAlgorithm_GetHashCode() As Long
HashAlgorithm_GetHashCode = GetHashCode
End Function
Private Property Get HashAlgorithm_Hash() As Byte()
HashAlgorithm_Hash = Hash
End Property
Private Property Get HashAlgorithm_HashSize() As Long
HashAlgorithm_HashSize = HashSize
End Property
Private Sub HashAlgorithm_Initialize()
Call Initialize
End Sub
Private Property Get HashAlgorithm_InputBlockSize() As Long
HashAlgorithm_InputBlockSize = InputBlockSize
End Property
Private Property Get HashAlgorithm_OutputBlockSize() As Long
HashAlgorithm_OutputBlockSize = OutputBlockSize
End Property
Private Function HashAlgorithm_ToString() As String
HashAlgorithm_ToString = ToString
End Function
Private Function HashAlgorithm_TransformBlock(InputBuffer() As Byte, ByVal InputOffset As Long, ByVal InputCount As Long, OutputBuffer() As Byte, ByVal OutputOffset As Long) As Long
HashAlgorithm_TransformBlock = TransformBlock(InputBuffer, InputOffset, InputCount, OutputBuffer, OutputOffset)
End Function
Private Function HashAlgorithm_TransformFinalBlock(InputBuffer() As Byte, ByVal InputOffset As Long, ByVal InputCount As Long) As Byte()
HashAlgorithm_TransformFinalBlock = TransformFinalBlock(InputBuffer, InputOffset, InputCount)
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ICryptoTransform Interface
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Property Get ICryptoTransform_CanReuseTransform() As Boolean
ICryptoTransform_CanReuseTransform = CanReuseTransform
End Property
Private Property Get ICryptoTransform_CanTransformMultipleBlocks() As Boolean
ICryptoTransform_CanTransformMultipleBlocks = CanTransformMultipleBlocks
End Property
Private Property Get ICryptoTransform_InputBlockSize() As Long
ICryptoTransform_InputBlockSize = InputBlockSize
End Property
Private Property Get ICryptoTransform_OutputBlockSize() As Long
ICryptoTransform_OutputBlockSize = OutputBlockSize
End Property
Private Function ICryptoTransform_TransformBlock(InputBuffer() As Byte, ByVal InputOffset As Long, ByVal InputCount As Long, OutputBuffer() As Byte, ByVal OutputOffset As Long) As Long
ICryptoTransform_TransformBlock = TransformBlock(InputBuffer, InputOffset, InputCount, OutputBuffer, OutputOffset)
End Function
Private Function ICryptoTransform_TransformFinalBlock(InputBuffer() As Byte, ByVal InputOffset As Long, ByVal InputCount As Long) As Byte()
ICryptoTransform_TransformFinalBlock = TransformFinalBlock(InputBuffer, InputOffset, InputCount)
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' KeyedHashAlgorithm Interface
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Property Let KeyedHashAlgorithm_Key(RHS() As Byte)
Call mBase.SetKey(RHS)
End Property
Private Property Get KeyedHashAlgorithm_Key() As Byte()
KeyedHashAlgorithm = Key
End Property
Private Property Get KeyedHashAlgorithm_CanReuseTransform() As Boolean
KeyedHashAlgorithm_CanReuseTransform = CanReuseTransform
End Property
Private Property Get KeyedHashAlgorithm_CanTransformMultipleBlocks() As Boolean
KeyedHashAlgorithm_CanTransformMultipleBlocks = CanTransformMultipleBlocks
End Property
Private Sub KeyedHashAlgorithm_Clear()
Call Clear
End Sub
Private Function KeyedHashAlgorithm_ComputeHash(Source As Variant, Optional Index As Variant, Optional Count As Variant) As Byte()
KeyedHashAlgorithm_ComputeHash = ComputeHash(Source, Index, Count)
End Function
Private Function KeyedHashAlgorithm_Equals(Value As Variant) As Boolean
KeyedHashAlgorithm_Equals = Equals(Value)
End Function
Private Function KeyedHashAlgorithm_GetHashCode() As Long
KeyedHashAlgorithm_GetHashCode = GetHashCode
End Function
Private Property Get KeyedHashAlgorithm_Hash() As Byte()
KeyedHashAlgorithm_Hash = Hash
End Property
Private Property Get KeyedHashAlgorithm_HashSize() As Long
KeyedHashAlgorithm_HashSize = HashSize
End Property
Private Sub KeyedHashAlgorithm_Initialize()
Call Initialize
End Sub
Private Property Get KeyedHashAlgorithm_InputBlockSize() As Long
KeyedHashAlgorithm_InputBlockSize = InputBlockSize
End Property
Private Property Get KeyedHashAlgorithm_OutputBlockSize() As Long
KeyedHashAlgorithm_OutputBlockSize = OutputBlockSize
End Property
Private Function KeyedHashAlgorithm_ToString() As String
KeyedHashAlgorithm_ToString = ToString
End Function
Private Function KeyedHashAlgorithm_TransformBlock(InputBuffer() As Byte, ByVal InputOffset As Long, ByVal InputCount As Long, OutputBuffer() As Byte, ByVal OutputOffset As Long) As Long
KeyedHashAlgorithm_TransformBlock = TransformBlock(InputBuffer, InputOffset, InputCount, OutputBuffer, OutputOffset)
End Function
Private Function KeyedHashAlgorithm_TransformFinalBlock(InputBuffer() As Byte, ByVal InputOffset As Long, ByVal InputCount As Long) As Byte()
KeyedHashAlgorithm_TransformFinalBlock = TransformFinalBlock(InputBuffer, InputOffset, InputCount)
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -