XSha1 function

From StealthBot Wiki
Jump to: navigation, search

The XSha1() function is available to StealthBot through the Script Support Class. This function returns a "broken" SHA-1 hash of the provided string.

Development

The XSha1 function was added to StealthBot for version 2.7.

Documentation

'// XSHA1
'// Returns the result of a non-standard Battle.net "broken" Sha-1 hash
'// Changed 10/18/2009 - Hdx
'//    Added Optional Argument "Spacer", This will go between every hex digit, people usually use Space$(1) for nice debugging print
'//    inHex will now properly pad characters that are < 0x10 with a leading 0, Chr$(6) becomes "06" instead of "6"
Public Function XSHA1(ByRef str As String, Optional ByVal inHex As Boolean = False, Optional SPACER As String = vbNullString) As String
    Dim i As Integer
    Dim s As String

    XSHA1 = modBNCSutil.hashPassword(str)

    If inHex Then
        For i = 1 To Len(XSHA1)
            s = StringFormat("{0}{1}{2}", s, IIf(i > 1, SPACER, vbNullString), ZeroOffset(Asc(Mid(XSHA1, i, 1)), 2))
        Next
        XSHA1 = s
    End If
End Function

Summary

Returns a "broken" SHA-1 hash of the specified value. This is the hash that is used to hash passwords for Battle.net before NLS.

Syntax

strHash = XSHA1(Value, [InHex], [Spacer])

Arguments

  • str is the value to hash.
  • inHex is an optional Boolean. If True is passed, the result will be a hexadecimal-representation of the hash 40-digits long. If False is passed (default), the result will be a 20-character string (may contain null characters).
  • spacer is an optional string. The function places this string between every hexadecimal byte. Conventionally use a space character (" ") to format the hash for debugging purposes. By default this is an empty string (""), making no spaces between hex bytes. This argument is ignored if inHex is False.

Returns

Returns a 20-character string value which is a broken SHA-1 hash of the specified string. If inHex was True, returns a 40-digit hexadecimal representation of the hash.

Examples

See also