Modify

Opened 12 years ago

Closed 9 years ago

Last modified 9 years ago

#2296 closed Feature Request (Completed)

SHA2 for Crypt.au3

Reported by: jNizM Owned by: BrewManNH
Milestone: 3.3.15.1 Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

see here:
http://autoit.de/index.php?page=Thread&threadID=35302

SHA2 for Crypt.au3

Global Const $CALG_SHA_256 = 0x0000800c
Global Const $CALG_SHA_384 = 0x0000800d
Global Const $CALG_SHA_512 = 0x0000800e

_Crypt_HashData.au3 | Helpfile

#include <Crypt.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $bAlgorithm = $CALG_SHA1, $iInputEdit = -1, $iOutputEdit = -1

GUICreate("Realtime Hashing", 400, 320)
$iInputEdit = GUICtrlCreateEdit("", 0, 0, 400, 150, $ES_WANTRETURN)
$iOutputEdit = GUICtrlCreateEdit("", 0, 150, 400, 150, $ES_READONLY)
Local $iCombo = GUICtrlCreateCombo("", 0, 300, 100, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "MD2|MD4|MD5|SHA1|SHA256|SHA384|SHA512", "SHA1")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW)

_Crypt_Startup() ; To optimize performance start the crypt library.

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $iCombo ; Check when the combobox is selected and retrieve the correct algorithm.
            Switch GUICtrlRead($iCombo) ; Read the combobox selection.
                Case "MD2"
                    $bAlgorithm = $CALG_MD2

                Case "MD4"
                    $bAlgorithm = $CALG_MD4

                Case "MD5"
                    $bAlgorithm = $CALG_MD5

                Case "SHA1"
                    $bAlgorithm = $CALG_SHA1
                
                Case "SHA256"
                    If (@OSVersion = "WIN_2000") Or (@OSVersion = "WIN_XPe") Or (@OSVersion = "WIN_XP") Or (@OSVersion = "WIN_2003") Then
                        MsgBox(16, "Error", "Sorry, this algorithm is not available. Windows Vista+ only.") ; Show an error if the system is not Windows Vista+.
                        ContinueLoop
                    EndIf
                    $bAlgorithm = $CALG_SHA_256
                
                Case "SHA384"
                    If (@OSVersion = "WIN_2000") Or (@OSVersion = "WIN_XPe") Or (@OSVersion = "WIN_XP") Or (@OSVersion = "WIN_2003") Then
                        MsgBox(16, "Error", "Sorry, this algorithm is not available. Windows Vista+ only.") ; Show an error if the system is not Windows Vista+.
                        ContinueLoop
                    EndIf
                    $bAlgorithm = $CALG_SHA_384
                    
                Case "SHA512"
                    If (@OSVersion = "WIN_2000") Or (@OSVersion = "WIN_XPe") Or (@OSVersion = "WIN_XP") Or (@OSVersion = "WIN_2003") Then
                        MsgBox(16, "Error", "Sorry, this algorithm is not available. Windows Vista+ only.") ; Show an error if the system is not Windows Vista+.
                        ContinueLoop
                    EndIf
                    $bAlgorithm = $CALG_SHA_512
            EndSwitch

            Local $sRead = GUICtrlRead($iInputEdit)
            If StringStripWS($sRead, 8) <> "" Then ; Check there is text available to hash.
                Local $bHash = _Crypt_HashData($sRead, $bAlgorithm) ; Create a hash of the text entered.
                GUICtrlSetData($iOutputEdit, $bHash) ; Set the output box with the hash data.
            EndIf
    EndSwitch
WEnd

_Crypt_Shutdown() ; Shutdown the crypt library.

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch _WinAPI_LoWord($wParam)
        Case $iInputEdit
            Switch _WinAPI_HiWord($wParam)
                Case $EN_CHANGE
                    Local $bHash = _Crypt_HashData(GUICtrlRead($iInputEdit), $bAlgorithm) ; Create a hash of the text entered.
                    GUICtrlSetData($iOutputEdit, $bHash) ; Set the output box with the hash data.
            EndSwitch
    EndSwitch
EndFunc   ;==>WM_COMMAND

Attachments (0)

Change History (10)

comment:1 Changed 12 years ago by TicketCleanup

  • Version 3.3.8.1 deleted

Automatic ticket cleanup.

comment:2 Changed 12 years ago by jNizM

Windows XP with SP3:
This algorithm is supported

Windows XP with SP2, Windows XP with SP1, and Windows XP:
This algorithm is not supported.

comment:3 Changed 12 years ago by anonymous

any reason why SHA_224 not available in the proposal?

comment:5 in reply to: ↑ 4 Changed 12 years ago by anonymous

Replying to jNizM:

ALG_ID (Windows)
http://msdn.microsoft.com/en-us/library/windows/desktop/aa375549(v=vs.85).aspx

thanks,
that certainly means that MS does not support it !!!

comment:6 Changed 12 years ago by guinness

  • Resolution set to Rejected
  • Status changed from new to closed

AutoIt supports Windows 2000 and above and thus adding these would cause more issues for very little benefit.

comment:7 Changed 11 years ago by guinness

Added as comments for now.

comment:8 Changed 9 years ago by BrewManNH

  • Resolution Rejected deleted
  • Status changed from closed to reopened

comment:9 Changed 9 years ago by BrewManNH

  • Owner set to BrewManNH
  • Status changed from reopened to accepted

comment:10 Changed 9 years ago by BrewManNH

  • Milestone set to 3.3.15.1
  • Resolution set to Completed
  • Status changed from accepted to closed

Changed by revision [11621] in version: 3.3.15.1

Version 0, edited 9 years ago by BrewManNH (next)

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain BrewManNH.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.