Всем привет.
@mshta "%~f0"&exit /b
html
<head>
<title>Hash Calculator</title>
<meta name="author" content="Greg Zakharov" />
<hta:application id="iHasher"
applicationname="Hash Calculator"
border="thin"
contextmenu="no"
maximizebutton="no"
minimizebutton="no"
scroll="no"
singleinstance="yes"
sysmenu="yes"
version="1.0" />
<style type="text/css">
html, body {
background: #eee;
font-size: 90%;
margin: 3px 3px;
padding: 0;
}
p {
font-weight: bold;
margin: 1px 1px;
padding: 0;
}
#filename {
width: 100%;
}
</style>
<script language="VBScript">
Sub Resize()
window.resizeTo 430, 130
End Sub
Sub GetHash()
Dim objFile, objSize, objBuff, objType, objHash, objDone
Dim objNS
document.getElementById("result").value = ""
objFile = document.getElementById("filename").value
If objFile = "" Then
alert("Nothing choosed.")
Exit Sub
End If
With CreateObject("Scripting.FileSystemObject")
objSize = .GetFile(objFile).Size
End With
If objSize = 0 Then
alert("Specified file has null length.")
Exit Sub
End If
With CreateObject("SAPI.SpFileStream")
.Open objFile, 0
.Read objBuff, objSize
.Close
End With
For Each h In hash
If h.checked Then
objType = LCase(h.value)
Exit For
End If
Next
objNS = "System.Security.Cryptography."
Select Case objType
Case "md5" Set objHash = CreateObject(objNS & "MD5CryptoServiceProvider")
Case "sha1" Set objHash = CreateObject(objNS & "SHA1Managed")
Case "sha256" Set objHash = CreateObject(objNS & "SHA256Managed")
Case "sha384" Set objHash = CreateObject(objNS & "SHA384Managed")
Case "sha512" Set objHash = CreateObject(objNS & "SHA512Managed")
Case "ripemd160" Set objHash = CreateObject(objNS & "RIPEMD160Managed")
End Select
objType = objHash.ComputeHash_2((objBuff))
For i = 1 To LenB(objType)
objDone = objDone & Right("0" & Hex(AscB(MidB(objType, i, 1))), 2)
Next
document.getElementById("result").value = LCase(objDone)
End Sub
</script>
</head>
<body onload="Resize()">
<p><input type="file" id="filename" onchange="GetHash()" /></p>
<p>
<input type="radio" name="hash" value="MD5" onclick="GetHash()" />MD5
<input type="radio" name="hash" value="SHA1" onclick="GetHash()" />SHA1
<input type="radio" name="hash" value="SHA256" checked="true" onclick="GetHash()" />SHA256
<input type="radio" name="hash" value="SHA384" onclick="GetHash()" />SHA384
<input type="radio" name="hash" value="SHA512" onclick="GetHash()" />SHA512
<input type="radio" name="hash" value="RIPEMD160" onclick="GetHash()" />RIPEMD160
</p>
<textarea cols="49" id="result"></textarea>
</body>
/html
На сегодня все.
Часто надо проверить hash-сумму подозрительного файла. После недолгих поисков в сети я нашел калькулятор с открытым кодом от Грега Захарова. Весьма изящное решение.
Все что ниже запихните в bat-файл. И будет вам счастье. В виде простенького калькулятора hash-суммы для любого файла. Не забудьте тег html взять в <>.
html
<head>
<title>Hash Calculator</title>
<meta name="author" content="Greg Zakharov" />
<hta:application id="iHasher"
applicationname="Hash Calculator"
border="thin"
contextmenu="no"
maximizebutton="no"
minimizebutton="no"
scroll="no"
singleinstance="yes"
sysmenu="yes"
version="1.0" />
<style type="text/css">
html, body {
background: #eee;
font-size: 90%;
margin: 3px 3px;
padding: 0;
}
p {
font-weight: bold;
margin: 1px 1px;
padding: 0;
}
#filename {
width: 100%;
}
</style>
<script language="VBScript">
Sub Resize()
window.resizeTo 430, 130
End Sub
Sub GetHash()
Dim objFile, objSize, objBuff, objType, objHash, objDone
Dim objNS
document.getElementById("result").value = ""
objFile = document.getElementById("filename").value
If objFile = "" Then
alert("Nothing choosed.")
Exit Sub
End If
With CreateObject("Scripting.FileSystemObject")
objSize = .GetFile(objFile).Size
End With
If objSize = 0 Then
alert("Specified file has null length.")
Exit Sub
End If
With CreateObject("SAPI.SpFileStream")
.Open objFile, 0
.Read objBuff, objSize
.Close
End With
For Each h In hash
If h.checked Then
objType = LCase(h.value)
Exit For
End If
Next
objNS = "System.Security.Cryptography."
Select Case objType
Case "md5" Set objHash = CreateObject(objNS & "MD5CryptoServiceProvider")
Case "sha1" Set objHash = CreateObject(objNS & "SHA1Managed")
Case "sha256" Set objHash = CreateObject(objNS & "SHA256Managed")
Case "sha384" Set objHash = CreateObject(objNS & "SHA384Managed")
Case "sha512" Set objHash = CreateObject(objNS & "SHA512Managed")
Case "ripemd160" Set objHash = CreateObject(objNS & "RIPEMD160Managed")
End Select
objType = objHash.ComputeHash_2((objBuff))
For i = 1 To LenB(objType)
objDone = objDone & Right("0" & Hex(AscB(MidB(objType, i, 1))), 2)
Next
document.getElementById("result").value = LCase(objDone)
End Sub
</script>
</head>
<body onload="Resize()">
<p><input type="file" id="filename" onchange="GetHash()" /></p>
<p>
<input type="radio" name="hash" value="MD5" onclick="GetHash()" />MD5
<input type="radio" name="hash" value="SHA1" onclick="GetHash()" />SHA1
<input type="radio" name="hash" value="SHA256" checked="true" onclick="GetHash()" />SHA256
<input type="radio" name="hash" value="SHA384" onclick="GetHash()" />SHA384
<input type="radio" name="hash" value="SHA512" onclick="GetHash()" />SHA512
<input type="radio" name="hash" value="RIPEMD160" onclick="GetHash()" />RIPEMD160
</p>
<textarea cols="49" id="result"></textarea>
</body>
/html
На сегодня все.
No comments:
Post a Comment
А что вы думаете по этому поводу?