주어진 파일에 대해 SHA512 값을 계산하기 위해 VBScript에서 코드를 작성하려고합니다. MSFT 설명서 에 따르면 SHA512Managed 개체의 ComputeHash 메서드에는 바이트 배열이 입력되어 있어야합니다. 그래서 ADODB를 사용하여 SHA512 값을 계산할 입력 파일을 읽었습니다 (AFAIK 때문에 VBScript에서 Byte 배열을 작성하는 방법은 없습니다). 그러나 런타임 오류 5, '잘못된 프로 시저 호출 또는 인수'메서드를 호출 할 때. 아래 코드의 변수 막대는 Byte() 유형입니다. - VBScript는 말합니다.VBScript 오류 5 'System.Security.Cryptography.SHA512Managed'로 sha512를 계산하려고 시도했습니다.
아무도 잘못되었다고 말할 수 있습니까?
코드 :
Option Explicit
'
'
'
Dim scs, ado
Dim bar, hsh
Set scs = CreateObject("System.Security.Cryptography.SHA512Managed")
Set ado = CreateObject("ADODB.Stream")
ado.type = 1 ' TypeBinary
ado.open
ado.LoadFromFile WScript.ScriptFullName
bar = ado.Read
ado.Close
MsgBox TypeName(bar) & "/" & LenB(bar) & "/" & Len(bar),,"Box 1"
' Displays : "Byte()/876/438"
On Error Resume Next
' Attempt 1
Set hsh = scs.ComputeHash(bar)
MsgBox Hex(Err.Number) & "/" & Err.Description,,"Set hsh = "
' Displays : "5/Invalid procedure call or argument"
' Attempt 2
hsh = scs.ComputeHash(bar)
MsgBox Hex(Err.Number) & "/" & Err.Description,,"hsh = "
' Displays : "5/Invalid procedure call or argument"
MsgBox TypeName(scs),,"scs" ' Displays : "SHA512Managed"
Set ado = Nothing
Set scs = Nothing
WScript.Quit
bar가 실행중인 스크립트를 참조하고 있습니다. 사용하지 않는 파일을 참조하는 동일한 오류가 발생합니까? – Sorceri