📄 rijndaelmanaged.cls
字号:
Equals = Object.Equals(Me, Value)
End Function
''
' Returns a psuedo-unique number used to help identify this
' object in memory. The current method is to return the value
' obtained from ObjPtr. If a different method needs to be impelmented
' then change the method here in this function.
'
' @return Returns a number identifing this instance.
'
Public Function GetHashCode() As Long
GetHashCode = ObjPtr(CUnk(Me))
End Function
''
' Returns a string representation of this object instance.
' The default method simply returns the application name
' and class name in which this class resides.
'
' @return Returns a string representation of this instance.
'
Public Function ToString() As String
ToString = Object.ToString(Me, App)
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Private Helpers
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function CreateCipher(ByRef RgbKey As Variant, ByRef RgbIV As Variant, ByVal IsEncrypting As Boolean) As RijndaelManagedTransform
If IsMissing(RgbKey) <> IsMissing(RgbIV) Then _
Throw Cor.NewArgumentException("Argument is missing.", IIf(IsMissing(RgbKey), "RgbKey", "RgbIV"))
Set CreateCipher = New RijndaelManagedTransform
Call CreateCipher.Init(mBase.CloneRgbKey(RgbKey), mBase.CloneRgbIV(RgbIV), mBase, IsEncrypting)
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Class Events
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Class_Initialize()
Set mBase = New SymmetricAlgorithmBase
With mBase
Call .AddLegalBlockSize(DEF_MINBLOCKSIZE, DEF_MAXBLOCKSIZE, DEF_BLOCKSKIPSIZE)
Call .AddLegalKeySize(DEF_MINKEYSIZE, DEF_MAXKEYSIZE, DEF_KEYSKIPSIZE)
.BlockSize = DEF_BLOCKSIZE
.KeySize = DEF_KEYSIZE
.FeedbackSize = DEF_FEEDBACKSIZE
.Mode = CipherMode.CBC
.Padding = PaddingMode.PKCS7
End With
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DES Interface
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Property Let Rijndael_BlockSize(ByVal RHS As Long)
BlockSize = RHS
End Property
Private Property Get Rijndael_BlockSize() As Long
Rijndael_BlockSize = BlockSize
End Property
Private Sub Rijndael_Clear()
Call Clear
End Sub
Private Function Rijndael_CreateDecryptor(Optional ByRef RgbKey As Variant, Optional ByRef RgbIV As Variant) As ICryptoTransform
Set Rijndael_CreateDecryptor = CreateDecryptor(RgbKey, RgbIV)
End Function
Private Function Rijndael_CreateEncryptor(Optional ByRef RgbKey As Variant, Optional ByRef RgbIV As Variant) As ICryptoTransform
Set Rijndael_CreateEncryptor = CreateEncryptor(RgbKey, RgbIV)
End Function
Private Function Rijndael_Equals(Value As Variant) As Boolean
Rijndael_Equals = Equals(Value)
End Function
Private Property Let Rijndael_FeedbackSize(ByVal RHS As Long)
FeedbackSize = RHS
End Property
Private Property Get Rijndael_FeedbackSize() As Long
Rijndael_FeedbackSize = FeedbackSize
End Property
Private Sub Rijndael_GenerateIV()
Call GenerateIV
End Sub
Private Sub Rijndael_GenerateKey()
Call GenerateKey
End Sub
Private Function Rijndael_GetHashCode() As Long
Rijndael_GetHashCode = GetHashCode
End Function
Private Property Let Rijndael_IV(RHS() As Byte)
Call mBase.SetIV(RHS)
End Property
Private Property Get Rijndael_IV() As Byte()
Rijndael_IV = IV
End Property
Private Property Let Rijndael_Key(RHS() As Byte)
Call mBase.SetKey(RHS)
End Property
Private Property Get Rijndael_Key() As Byte()
Rijndael_Key = Key
End Property
Private Property Let Rijndael_KeySize(ByVal RHS As Long)
KeySize = RHS
End Property
Private Property Get Rijndael_KeySize() As Long
Rijndael_KeySize = KeySize
End Property
Private Property Get Rijndael_LegalBlockSizes() As KeySizes()
Rijndael_LegalBlockSizes = LegalBlockSizes
End Property
Private Property Get Rijndael_LegalKeySizes() As KeySizes()
Rijndael_LegalKeySizes = LegalKeySizes
End Property
Private Property Let Rijndael_Mode(ByVal RHS As CipherMode)
Mode = RHS
End Property
Private Property Get Rijndael_Mode() As CipherMode
Rijndael_Mode = Mode
End Property
Private Property Let Rijndael_Padding(ByVal RHS As PaddingMode)
Padding = RHS
End Property
Private Property Get Rijndael_Padding() As PaddingMode
Rijndael_Padding = Padding
End Property
Private Function Rijndael_ToString() As String
Rijndael_ToString = ToString
End Function
Private Function Rijndael_ValidKeySize(ByVal BitLength As Long) As Boolean
Rijndael_ValidKeySize = ValidKeySize(BitLength)
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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' SymmetricAlgorithm Interface
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Property Let SymmetricAlgorithm_BlockSize(ByVal RHS As Long)
BlockSize = RHS
End Property
Private Property Get SymmetricAlgorithm_BlockSize() As Long
SymmetricAlgorithm_BlockSize = BlockSize
End Property
Private Sub SymmetricAlgorithm_Clear()
Call Clear
End Sub
Private Function SymmetricAlgorithm_CreateDecryptor(Optional ByRef RgbKey As Variant, Optional ByRef RgbIV As Variant) As ICryptoTransform
Set SymmetricAlgorithm_CreateDecryptor = CreateDecryptor(RgbKey, RgbIV)
End Function
Private Function SymmetricAlgorithm_CreateEncryptor(Optional ByRef RgbKey As Variant, Optional ByRef RgbIV As Variant) As ICryptoTransform
Set SymmetricAlgorithm_CreateEncryptor = CreateEncryptor(RgbKey, RgbIV)
End Function
Private Function SymmetricAlgorithm_Equals(Value As Variant) As Boolean
SymmetricAlgorithm_Equals = Equals(Value)
End Function
Private Property Let SymmetricAlgorithm_FeedbackSize(ByVal RHS As Long)
FeedbackSize = RHS
End Property
Private Property Get SymmetricAlgorithm_FeedbackSize() As Long
SymmetricAlgorithm_FeedbackSize = FeedbackSize
End Property
Private Sub SymmetricAlgorithm_GenerateIV()
Call GenerateIV
End Sub
Private Sub SymmetricAlgorithm_GenerateKey()
Call GenerateKey
End Sub
Private Function SymmetricAlgorithm_GetHashCode() As Long
SymmetricAlgorithm_GetHashCode = GetHashCode
End Function
Private Property Let SymmetricAlgorithm_IV(RHS() As Byte)
Call mBase.SetIV(RHS)
End Property
Private Property Get SymmetricAlgorithm_IV() As Byte()
SymmetricAlgorithm_IV = IV
End Property
Private Property Let SymmetricAlgorithm_Key(RHS() As Byte)
Call mBase.SetKey(RHS)
End Property
Private Property Get SymmetricAlgorithm_Key() As Byte()
SymmetricAlgorithm_Key = Key
End Property
Private Property Let SymmetricAlgorithm_KeySize(ByVal RHS As Long)
KeySize = RHS
End Property
Private Property Get SymmetricAlgorithm_KeySize() As Long
SymmetricAlgorithm_KeySize = KeySize
End Property
Private Property Get SymmetricAlgorithm_LegalBlockSizes() As KeySizes()
SymmetricAlgorithm_LegalBlockSizes = LegalBlockSizes
End Property
Private Property Get SymmetricAlgorithm_LegalKeySizes() As KeySizes()
SymmetricAlgorithm_LegalKeySizes = LegalKeySizes
End Property
Private Property Let SymmetricAlgorithm_Mode(ByVal RHS As CipherMode)
Mode = RHS
End Property
Private Property Get SymmetricAlgorithm_Mode() As CipherMode
SymmetricAlgorithm_Mode = Mode
End Property
Private Property Let SymmetricAlgorithm_Padding(ByVal RHS As PaddingMode)
Padding = RHS
End Property
Private Property Get SymmetricAlgorithm_Padding() As PaddingMode
SymmetricAlgorithm_Padding = Padding
End Property
Private Function SymmetricAlgorithm_ToString() As String
SymmetricAlgorithm_ToString = ToString
End Function
Private Function SymmetricAlgorithm_ValidKeySize(ByVal BitLength As Long) As Boolean
SymmetricAlgorithm_ValidKeySize = ValidKeySize(BitLength)
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -