【发布时间】:2018-03-05 18:29:02
【问题描述】:
我参考这个问题:PBKDF2 Excel UDF and how to concatenate INT(i)
OP 没有为他的“ConcatenateArrayInPlace”-Function 提供代码,该函数包含在他对原始问题的自行找到的解决方案中。我正在尝试自己创建该功能。但是,我无处可去。
有人知道上述功能是如何工作的吗?
最好的,
碧玉
【问题讨论】:
标签: arrays vba concatenation
我参考这个问题:PBKDF2 Excel UDF and how to concatenate INT(i)
OP 没有为他的“ConcatenateArrayInPlace”-Function 提供代码,该函数包含在他对原始问题的自行找到的解决方案中。我正在尝试自己创建该功能。但是,我无处可去。
有人知道上述功能是如何工作的吗?
最好的,
碧玉
【问题讨论】:
标签: arrays vba concatenation
我相信以下内容会复制丢失的代码:
Sub ConcatenateArrayInPlace(ByRef ab1() As Byte, ByRef ab2() As Byte)
Dim origUBound As Long
Dim i As Long
origUBound = UBound(ab1)
ReDim Preserve ab1(LBound(ab1) To origUBound + 1 + UBound(ab2) - LBound(ab2))
For i = LBound(ab2) To UBound(ab2)
ab1(origUBound + 1 + i - LBound(ab2)) = ab2(i)
Next
End Sub
它将通过附加指定为第二个参数的数组来更新指定为第一个参数的数组。
【讨论】:
我想我找到了解决办法。
我将 PBKDF2-Code 更改如下:
outputBytes = ConcatenateArrayInPlace(outputBytes, tempBytes)
(而不是ConcatenateArrayInPlace outputBytes, tempBytes)
我插入了以下函数:
Function ConcatenateArrayInPlace(ab1() As Byte, ab2() As Byte)
Dim ab3() As Byte
Dim i As Long
ab3 = ab1
ReDim Preserve ab3(UBound(ab1) + UBound(ab2))
For i = 0 To UBound(ab2)
ab3(i + UBound(ab1)) = ab2(i)
Next
ConcatenateArrayInPlace = ab3
End Function
现在可以了。
最好的,
碧玉
【讨论】:
hashEncoding 类型在哪里定义?
Optional ByVal encodeHash As String = "heHex"。在函数中,我使用了以下代码:If encodeHash = "heBase64" Then PBKDF2 = ConvToBase64String(outputBytes) ElseIf encodeHash = "heHex" Then PBKDF2 = ConvToHexString(outputBytes) Else PBKDF2 = outputBytes End If