Sign in to follow this  
Followers 0
zelles

Crypto-Currency WalletSync

2 posts in this topic

#1 ·  Posted (edited)

WalletSync, Sync/Backup your crypto-currency wallets.

**Version 0.0.0.2 has been released adding the option to sync by FTP and not just locally.

This program will sync any wallet.dat files found in their default location, AppData/Roaming/*/wallet.dat... The program will make a copy of all the wallets in a SyncData folder found in the script directory where WalletSync is run.

The sync runs once every minute and can be minimized to the system tray to constantly stay syncing, a backup, in the background.

Version 0.0.0.2 Source Code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Icon.ico
#AutoIt3Wrapper_Res_Comment=Keep a sync'd backup of your crypto currency wallets locally and optionally with a FTP server.
#AutoIt3Wrapper_Res_Description=Keep a sync'd copy of all the crypto-currency wallet.dats found in there default locations on you PC.
#AutoIt3Wrapper_Res_Fileversion=0.0.0.2
#AutoIt3Wrapper_Res_LegalCopyright=Copyright 2014 zelles
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;#NoTrayIcon
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <FTPEx.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <TrayConstants.au3>
#include <WindowsConstants.au3>

_Singleton("zellesWalletSync2")

OnAutoItExitRegister("CloseSync")

Opt("TrayMenuMode", 3)

Global $SYNC_OPERATION = False

If Not FileExists(@ScriptDir & "\WalletSync_temp") Then DirCreate(@ScriptDir & "\WalletSync_temp")
FileInstall("C:\AIP\Logo.jpg", @ScriptDir & "\WalletSync_temp\Logo.jpg")
If Not FileExists(@ScriptDir & "\config.ini") Then
    IniWriteSection(@ScriptDir & "\config.ini", "config", "speed=60")
    IniWrite(@ScriptDir & "\config.ini", "config", "ftpserver", "none")
    IniWrite(@ScriptDir & "\config.ini", "config", "ftpport", "21")
    IniWrite(@ScriptDir & "\config.ini", "config", "ftpusername", "none")
    IniWrite(@ScriptDir & "\config.ini", "config", "ftppassword", "none")
EndIf

Global $SYNC_SPEED = IniRead(@ScriptDir & "\config.ini", "config", "speed", "60")
Global $SYNC_FTPSERVER = IniRead(@ScriptDir & "\config.ini", "config", "ftpserver", "none")
Global $SYNC_FTPPORT = IniRead(@ScriptDir & "\config.ini", "config", "ftpport", "21")
Global $SYNC_FTPUSER = IniRead(@ScriptDir & "\config.ini", "config", "ftpusername", "none")
Global $SYNC_FTPPASS = IniRead(@ScriptDir & "\config.ini", "config", "ftppassword", "none")

Global $GUI_Wallet_Sync = GUICreate("WalletSync, created by zelles", 370, 189, 245, 163)
GUISetBkColor(0xFFFFFF)
Global $GUI_Tab1 = GUICtrlCreateTab(5, 5, 361, 177)
Global $GUI_TabSheet1 = GUICtrlCreateTabItem("Overview")
Global $GUI_Logo = GUICtrlCreatePic(@ScriptDir & "\WalletSync_temp\Logo.jpg", 17, 46, 100, 100)
Global $GUI_Group1 = GUICtrlCreateGroup("Sync Options", 119, 55, 233, 89)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $GUI_CheckboxLocal = GUICtrlCreateCheckbox("Local", 135, 79, 57, 17)
GUICtrlSetState($GUI_CheckboxLocal, $GUI_CHECKED)
GUICtrlSetState($GUI_CheckboxLocal, $GUI_DISABLE)
Global $GUI_CheckboxFTP = GUICtrlCreateCheckbox("FTP", 135, 111, 57, 17)
Global $GUI_CheckboxOther1 = GUICtrlCreateCheckbox("Other", 199, 79, 57, 17)
GUICtrlSetState($GUI_CheckboxOther1, $GUI_DISABLE)
Global $GUI_CheckboxOther2 = GUICtrlCreateCheckbox("Other", 199, 111, 57, 17)
GUICtrlSetState($GUI_CheckboxOther2, $GUI_DISABLE)
Global $GUI_ButtonStart = GUICtrlCreateButton("Start", 266, 75, 75, 25)
Global $GUI_ButtonStop = GUICtrlCreateButton("Stop", 266, 107, 75, 25)
GUICtrlSetState($GUI_ButtonStop, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GUI_TabSheet2 = GUICtrlCreateTabItem("Status")
Global $GUI_Group6 = GUICtrlCreateGroup("Current Sync Status", 21, 65, 329, 73)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $GUI_SyncStatus = GUICtrlCreateLabel("Sync is turned off...", 40, 96, 294, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GUI_TabSheet3 = GUICtrlCreateTabItem("Local")
Global $GUI_Group2 = GUICtrlCreateGroup("Local Output", 22, 64, 329, 73)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $GUI_InputLocalOutput = GUICtrlCreateInput(@ScriptDir & "\SyncData", 35, 92, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GUI_TabSheet4 = GUICtrlCreateTabItem("FTP")
Global $GUI_Group5 = GUICtrlCreateGroup("FTP Settings", 21, 49, 329, 105)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $GUI_Label2 = GUICtrlCreateLabel("Server:", 37, 73, 38, 17)
Global $GUI_Label3 = GUICtrlCreateLabel("Port:", 37, 97, 26, 17)
Global $GUI_Label1 = GUICtrlCreateLabel("Username:", 189, 73, 55, 17)
Global $GUI_Label4 = GUICtrlCreateLabel("Password:", 189, 97, 53, 17)
Global $GUI_InputFTPServer = GUICtrlCreateInput($SYNC_FTPSERVER, 79, 70, 105, 21)
Global $GUI_InputFTPPort = GUICtrlCreateInput($SYNC_FTPPORT, 79, 94, 105, 21)
Global $GUI_InputFTPUsername = GUICtrlCreateInput($SYNC_FTPUSER, 247, 70, 89, 21)
Global $GUI_InputFTPPassword = GUICtrlCreateInput($SYNC_FTPPASS, 247, 94, 89, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
Global $GUI_ButtonFTPUpdate = GUICtrlCreateButton("Update", 264, 120, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GUI_TabSheet6 = GUICtrlCreateTabItem("Scanner")
Global $GUI_Group4 = GUICtrlCreateGroup("Sync Scanner", 21, 33, 329, 137)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $GUI_ComboSpeed = GUICtrlCreateCombo("1 minute", 40, 56, 209, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($GUI_ComboSpeed, "5 minutes|10 minutes|30 minutes|1 hour", "1 minute")
Global $GUI_ButtonUpdateSpeed = GUICtrlCreateButton("Update", 256, 56, 75, 21)
Global $GUI_Wallets_Found = GUICtrlCreateList("", 120, 88, 209, 69, BitOR($LBS_NOTIFY,$LBS_SORT,$WS_VSCROLL))
Global $GUI_Label5 = GUICtrlCreateLabel("Wallets Found:", 40, 86, 75, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW, $GUI_Wallet_Sync)

Global $GUI_Tray_Open = TrayCreateItem("Open WalletSync")
TrayCreateItem("")
Global $GUI_Tray_Exit = TrayCreateItem("Exit")
TraySetState($TRAY_ICONSTATE_SHOW)

Global $SyncAdded = "||"
Global $SyncScan = FileFindFirstFile(@AppDataDir & "\*.*")
While 1
    GUI_Events()
    If $SYNC_OPERATION = False Then ContinueLoop
    Local $SyncScanResult = FileFindNextFile($SyncScan)
    If @error Then SyncReset()
    If @extended = 1 Then
        If FileExists(@AppDataDir & "\" & $SyncScanResult & "\wallet.dat") Then
            GUICtrlSetData($GUI_SyncStatus, $SyncScanResult)
            If Not StringInStr($SyncAdded, "||" & $SyncScanResult & "||") Then
                $SyncAdded &= $SyncScanResult & "||"
                GUICtrlSetData($GUI_Wallets_Found, $SyncScanResult)
            EndIf
            If GUICtrlRead($GUI_CheckboxLocal) = $GUI_CHECKED Then
                If Not FileExists(@ScriptDir & "\SyncData") Then DirCreate(@ScriptDir & "\SyncData")
                If Not FileExists(@ScriptDir & "\SyncData\" & $SyncScanResult) Then DirCreate(@ScriptDir & "\SyncData\" & $SyncScanResult)
                FileCopy(@AppDataDir & "\" & $SyncScanResult & "\wallet.dat", @ScriptDir & "\SyncData\" & $SyncScanResult & "\wallet.dat", 1)
            EndIf
        EndIf
    EndIf
WEnd

Func SyncReset()
    If $SYNC_OPERATION = True Then
        If GUICtrlRead($GUI_CheckboxFTP) = $GUI_CHECKED Then
            GUICtrlSetData($GUI_SyncStatus, "Sending to FTP server...")
            $SyncFTPOpen = _FTP_Open('FTP')
            $SyncFTPConn = _FTP_Connect($SyncFTPOpen, $SYNC_FTPSERVER, $SYNC_FTPUSER, $SYNC_FTPPASS, "1", $SYNC_FTPPORT)
            _FTP_DirPutContents($SyncFTPConn, @ScriptDir & "\SyncData", "", 1)
            _FTP_Close($SyncFTPOpen)
            _FTP_Close($SyncFTPConn)
        EndIf
        GUICtrlSetData($GUI_SyncStatus, "Sleeping...")
    EndIf
    FileClose($SyncScan)
    Local $SyncTimer = TimerInit()
    Do
        GUI_Events()
        Sleep(10)
    Until Round(TimerDiff($SyncTimer)/1000, 0) > $SYNC_SPEED
    Global $SyncScan = FileFindFirstFile(@AppDataDir & "\*.*")
EndFunc

Func GUI_Events()
    Switch TrayGetMsg()
        Case $GUI_Tray_Open
            GUISetState(@SW_SHOW, $GUI_Wallet_Sync)
            WinSetState($GUI_Wallet_Sync, "", @SW_RESTORE)
        Case $GUI_Tray_Exit
            CloseSync()
    EndSwitch
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            CloseSync()
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_Hide, $GUI_Wallet_Sync)
            TrayTip("WalletSync", "Minimized to the system tray...", 4)
        Case $GUI_ButtonStart
            GUICtrlSetState($GUI_ButtonStart, $GUI_DISABLE)
            GUICtrlSetState($GUI_ButtonStop, $GUI_ENABLE)
            $SYNC_OPERATION = True
        Case $GUI_ButtonStop
            GUICtrlSetState($GUI_ButtonStop, $GUI_DISABLE)
            GUICtrlSetState($GUI_ButtonStart, $GUI_ENABLE)
            GUICtrlSetData($GUI_SyncStatus, "Sync is turned off...")
            $SYNC_OPERATION = False
        Case $GUI_ButtonUpdateSpeed
            Switch GUICtrlRead($GUI_ComboSpeed)
                Case "5 minutes"
                    $SYNC_SPEED = 300
                    IniDelete(@ScriptDir & "\config.ini", "config", "speed")
                    IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED)
                    MsgBox(0, "WalletSync Response", "The speed was updated to 5 minute intervals.")
                Case "10 minutes"
                    $SYNC_SPEED = 600
                    IniDelete(@ScriptDir & "\config.ini", "config", "speed")
                    IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED)
                    MsgBox(0, "WalletSync Response", "The speed was updated to 10 minute intervals.")
                Case "30 minutes"
                    $SYNC_SPEED = 1800
                    IniDelete(@ScriptDir & "\config.ini", "config", "speed")
                    IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED)
                    MsgBox(0, "WalletSync Response", "The speed was updated to 30 minute intervals.")
                Case "1 hour"
                    $SYNC_SPEED = 3600
                    IniDelete(@ScriptDir & "\config.ini", "config", "speed")
                    IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED)
                    MsgBox(0, "WalletSync Response", "The speed was updated to 1 hour intervals.")
                Case Else
                    $SYNC_SPEED = 60
                    IniDelete(@ScriptDir & "\config.ini", "config", "speed")
                    IniWrite(@ScriptDir & "\config.ini", "config", "speed", $SYNC_SPEED)
                    MsgBox(0, "WalletSync Response", "The speed was updated to 1 minute intervals.")
            EndSwitch
        Case $GUI_ButtonFTPUpdate
            $SYNC_FTPSERVER = GUICtrlRead($GUI_InputFTPServer)
            $SYNC_FTPPORT = GUICtrlRead($GUI_InputFTPPort)
            $SYNC_FTPUSER = GUICtrlRead($GUI_InputFTPUsername)
            $SYNC_FTPPASS = GUICtrlRead($GUI_InputFTPPassword)
            IniDelete(@ScriptDir & "\config.ini", "config", "ftpserver")
            IniDelete(@ScriptDir & "\config.ini", "config", "ftpport")
            IniDelete(@ScriptDir & "\config.ini", "config", "ftpusername")
            IniDelete(@ScriptDir & "\config.ini", "config", "ftppassword")
            IniWrite(@ScriptDir & "\config.ini", "config", "ftpserver", $SYNC_FTPSERVER)
            IniWrite(@ScriptDir & "\config.ini", "config", "ftpport", $SYNC_FTPPORT)
            IniWrite(@ScriptDir & "\config.ini", "config", "ftpusername", $SYNC_FTPUSER)
            IniWrite(@ScriptDir & "\config.ini", "config", "ftppassword", $SYNC_FTPPASS)
            MsgBox(0, "WalletSync Response", "The ftp credentials were updated.")
    EndSwitch
EndFunc

Func CloseSync()
    FileClose($SyncScan)
    If FileExists(@ScriptDir & "\WalletSync_temp") Then DirRemove(@ScriptDir & "\WalletSync_temp", 1)
    Exit
EndFunc

Version 0.0.0.1 Source Code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Icon.ico
#AutoIt3Wrapper_Res_Comment=Backup your crypto currency wallets every minute.
#AutoIt3Wrapper_Res_Description=Keep a syncd copy of all the crypto-currency wallet.dats found in there default locations on you PC.
#AutoIt3Wrapper_Res_Fileversion=0.0.0.1
#AutoIt3Wrapper_Res_LegalCopyright=Copyright 2014 zelles
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <TrayConstants.au3>
#include <WindowsConstants.au3>

_Singleton("zellesWalletSync")

OnAutoItExitRegister("CloseSync")

Opt("TrayMenuMode", 3)

Global $GUI_Wallet_Sync = GUICreate("Wallet Sync", 162, 196, 258, 150)
Global $GUI_File = GUICtrlCreateMenu("&File")
Global $GUI_File_Minimize = GUICtrlCreateMenuItem("&Minimize", $GUI_File)
Global $GUI_File_Exit = GUICtrlCreateMenuItem("&Exit", $GUI_File)
Global $GUI_Help = GUICtrlCreateMenu("&Help")
Global $GUI_Help_About = GUICtrlCreateMenuItem("&About", $GUI_Help)
Local $GUI_Label1 = GUICtrlCreateLabel("Backing Up:", 8, 8, 95, 19)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
Global $GUI_Label2 = GUICtrlCreateLabel("Label2", 24, 32, 132, 17)
Local $GUI_Label3 = GUICtrlCreateLabel("Detected Wallets:", 8, 56, 104, 19)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
Global $GUI_Wallets_Found = GUICtrlCreateList("", 0, 80, 161, 95, BitOR($LBS_NOTIFY,$LBS_SORT,$WS_VSCROLL))
GUISetState(@SW_SHOW, $GUI_Wallet_Sync)

Global $GUI_Tray_Open = TrayCreateItem("Open WalletSync")
TrayCreateItem("")
Global $GUI_Tray_Exit = TrayCreateItem("Exit")
TraySetState($TRAY_ICONSTATE_SHOW)

Global $SyncAdded = "||"
Global $SyncScan = FileFindFirstFile(@AppDataDir & "\*.*")
While 1
    GUI_Events()
    Local $SyncScanResult = FileFindNextFile($SyncScan)
    If @error Then SyncReset()
    If @extended = 1 Then
        If FileExists(@AppDataDir & "\" & $SyncScanResult & "\wallet.dat") Then
            GUICtrlSetData($GUI_Label2, $SyncScanResult)
            If Not StringInStr($SyncAdded, "||" & $SyncScanResult & "||") Then
                $SyncAdded &= $SyncScanResult & "||"
                GUICtrlSetData($GUI_Wallets_Found, $SyncScanResult)
            EndIf
            If Not FileExists(@ScriptDir & "\SyncData") Then DirCreate(@ScriptDir & "\SyncData")
            If Not FileExists(@ScriptDir & "\SyncData\" & $SyncScanResult) Then DirCreate(@ScriptDir & "\SyncData\" & $SyncScanResult)
            FileCopy(@AppDataDir & "\" & $SyncScanResult & "\wallet.dat", @ScriptDir & "\SyncData\" & $SyncScanResult & "\wallet.dat", 1)
        EndIf
    EndIf
WEnd

Func SyncReset()
    GUICtrlSetData($GUI_Label2, "Sleeping...")
    FileClose($SyncScan)
    Local $SyncTimer = TimerInit()
    Do
        GUI_Events()
        Sleep(10)
    Until Round(TimerDiff($SyncTimer)/1000, 0) > 60
    Global $SyncScan = FileFindFirstFile(@AppDataDir & "\*.*")
EndFunc

Func GUI_Events()
    Switch TrayGetMsg()
        Case $GUI_Tray_Open
            GUISetState(@SW_SHOW, $GUI_Wallet_Sync)
            WinSetState($GUI_Wallet_Sync, "", @SW_RESTORE)
        Case $GUI_Tray_Exit
            CloseSync()
    EndSwitch
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            CloseSync()
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_Hide, $GUI_Wallet_Sync)
            TrayTip("WalletSync", "Minimized to the system tray...", 4)
        Case $GUI_File_Exit
            CloseSync()
        Case $GUI_File_Minimize
            GUISetState(@SW_Hide, $GUI_Wallet_Sync)
            TrayTip("WalletSync", "Minimized to the system tray...", 4)
        Case $GUI_Help_About
            MsgBox(0, "WalletSync", "A simple tools to sync all your crypto-currencies wallet.dat" & @CRLF & "files to a folder for backup purposes. Created by zelles")
    EndSwitch
EndFunc

Func CloseSync()
    FileClose($SyncScan)
    Exit
EndFunc

Version 0.0.0.1 Source Code:

WalletSync_v_0.0.0.1_source.zip

Version 0.0.0.1 Windows Binary:

WalletSync_v_0.0.0.1_x86.zip

 

New Version 0.0.0.2 with FTP:

https://github.com/zelles/WalletSync

Edited by zelles

Share this post


Link to post
Share on other sites



Version 0.0.0.2 Released:

Added the option to sync all the wallets found to a FTP server.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • minxomat
      By minxomat
      PRNG
      Here's a small PRNG called fliptag. It uses mostly linear math and its state can be completely kept within only 6 "registers" and the implementation is only 27 lines of code long.
      Verification
      I ran ent, DIEHARD and the NIST.GOV test suite against it (though I only did all the tests for one fixed seed). I re-ran ent with this, because this implementation has a system-time dependent seed.
      fliptag has 4 seed parameters, of which 3 are optional. The first one is the genesis seed and determines the starting state. Because this seed is very sensitive to small decimal changes, the current system tickcount (modified) is used in addition to the current system time. (AutoIts MT uses time(NULL))
      Here are some sample ent results from the AutoIt test suite, which generates a 1,5 MB file from random bytes:

       
      Conclusion
      1. Entropy
      A truly random sequence has an entropy value of 8.0. This is however not achievable by any software PRNG. Both PRNG are on par and have a very respectable entropy value.
      2. Compression
      A dense file (with high entropy) cannot be compressed. Both PRNG achieve perfect scores.
      3. Chi²
      The chi-square test is the most commonly used test for the randomness of data, and is extremely sensitive to errors in pseudorandom sequence generators. The chi-square distribution is calculated for the stream of bytes in the file and expressed as an absolute number and a percentage which indicates how frequently a truly random sequence would exceed the value calculated. We interpret the percentage as the degree to which the sequence tested is suspected of being non-random. If the percentage is greater than 99% or less than 1%, the sequence is almost certainly not random. If the percentage is between 99% and 95% or between 1% and 5%, the sequence is suspect. Percentages between 90% and 95% and 5% and 10% indicate the sequence is “almost suspect”.
      Both PRNGs achieve very good results. For comparison, Unix' rand() achieves a catastrophic 0.01, a Park & Miller PRNG will achieve roughly 97.5, while a truly - physical - random sequence will result in a Chi² score of about 40.9. 
      4. Arithmetic mean value
      Truly random sequences have an arithmetic mean value of exactly 127.5 (0xFF * 0.5). Both PRNG achieve near-perfect scores.
      5. Monte Carlo Pi
      Each successive sequence of six bytes is used as 24 bit X and Y co-ordinates within a square. If the distance of the randomly-generated point is less than the radius of a circle inscribed within the square, the six-byte sequence is considered a “hit”. The percentage of hits can be used to calculate the value of Pi. For very large streams (this approximation converges very slowly), the value will approach the correct value of Pi if the sequence is close to random. 
      Considering that even radioactive decay (true physical randomness) will not achieve better results than both PRNGs. So the scores are almost perfect.
      6. Serial Correlation
      This quantity measures the extent to which each byte in the file depends upon the previous byte. For random sequences, this value (which can be positive or negative) will, of course, be close to zero. A non-random byte stream such as a C program will yield a serial correlation coefficient on the order of 0.5. Wildly predictable data such as uncompressed bitmaps will exhibit serial correlation coefficients approaching 1.
      Both PRNGs achieve very good results.
       
      Download
      fliptag-3.1.zip
       
    • Rickname
      By Rickname
      The StringToByte function , I expected to return 0s and 1s as strings displayed, but in fact it returns in hex if Im not wrong like 0xH3J4H....
      How can I make to return to me the expression of a string in bits ?
       
    • SimpleC
      By SimpleC
      Hello everybody! 
      I'm having trouble with rounding.  The program I'm using rounds decimals down. Autoit's round function rounds them up.
      Example:
      round(174.126, 2) = 174.13
      I need that round to be 174.12.   
       
      Here's the actually script:
      #include <ButtonConstants.au3>
      #include <EditConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <StaticConstants.au3>
      #include <WindowsConstants.au3>
      #Region ### START Koda GUI section ### Form=C:Program FilesAutoinstallForm1.kxf
      $Form1 = GUICreate("AutoCalc", 227, 200, 15, 15, $WS_EX_TOPMOST)
      $Button1 = GUICtrlCreateButton("Calculate", 8, 144, 99, 25)
      $Button2 = GUICtrlCreateButton("Close", 120, 144, 91, 25)
      $Label4 = GUICtrlCreateLabel("", 72, 136, 4, 4)
      GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
      $Group1 = GUICtrlCreateGroup("Input", 8, 8, 209, 129)
      $Label1 = GUICtrlCreateLabel("Rate", 16, 32, 27, 17)
      $Label2 = GUICtrlCreateLabel("Number of Nights", 16, 64, 86, 17)
      $Input1 = GUICtrlCreateInput("0.00", 112, 24, 89, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_RIGHT))
      $Label3 = GUICtrlCreateLabel("Total", 16, 96, 45, 28)
      GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
      $Input2 = GUICtrlCreateInput("1", 112, 56, 89, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_RIGHT))
      ;$Label5 = GUICtrlCreateLabel("0.00", 136, 96, 39, 28)
      GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
      GUICtrlCreateGroup("", -99, -99, 1, 1)
      GUISetState(@SW_SHOW)
      #EndRegion ### END Koda GUI section ###
      While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
        Case $GUI_EVENT_CLOSE
         Exit
         case $Button1
         ;$val = round((((((GUICtrlRead($input1) * .1545) + GUICtrlRead($input1)) + 1.5 + .13) * GUICtrlRead($input2))), 2)
         $val = (((((GUICtrlRead($input1) * .1545) + GUICtrlRead($input1)) + 1.5 + .13) * GUICtrlRead($input2)))
         $Label5 = GUICtrlCreateLabel($val, 136, 96, 39, 28)
         case $Button2
         Exit
       EndSwitch
      WEnd
    • JoshDB
      By JoshDB
      Hi all, I need to generate an HMAC hash using SHA512 according to a certain API's specs and the only HMAC example I've seen () does not work as I need it do, even adapting it from a 64-bit blocksize to 512 and adding Ward's_SHA512 UDF.

      I've tried the following:


      Func _HashHMAC512($key, $message) $key = _StringRepeat("0", 512 - StringLen($key)) & $key ; keys shorter than blocksize are zero-padded ('?' is concatenation) $o_key_pad = BitXOR(0x5c * 512, $key) ; Where blocksize is that of the underlying hash function $i_key_pad = BitXOR(0x36 * 512, $key) ; Where ? is exclusive or (XOR) Return _SHA512($o_key_pad & _SHA512($i_key_pad & $message)) EndFunc
      But, of course, it doesn't work (I suspect I'm doing something very blatantly wrong, but as I lack fundamental understanding about binary and hex number formats I can't see what's the issue right off the top of my head.)

      Note: in my case $key will always by 68 characters long so it will always prepend the leading zeroes.

      As a litmus test, I need to hash the message 1239348906120181 with the key ba63a816f030cefeea4803cd593569ce23f3815d0cc8c56d9194df6226dca2f0f48239698bc68991cfac387449b07b0f722f6f3df761dbc1fe8894dd65ff00b2 and receive 2610740031eeab61bbe6cd3f08daa6186ff0d59f5ec045dbb0e194fea8998b4f3d1da9aae0f718f8c126d6418302e081d68a82f0576eb266b68f26dc3459b62f as the output.

      I've been working on this for the past 4-odd hours now, to no avail. I really, really don't want to have to restart my project in python or php or somesuch... or, for that matter, write the hash function in js, python, or php and somehow bootleg that single function's results into my au3 project. I would greatly appreciate any help from ye wise ents, even if it's just a nudge in the right direction.
    • FireFox
      By FireFox
      Hi,
      I'm wondering how to make a zero-fill right shift in autoit as far as the BitShift function has no parameter for this.

      Here is an example in javascript : https://developer.mozilla.org/en-US/docs/Javascript/Reference/Operators/Bitwise_Operators#>>>_(Zero-fill_right_shift)

      Thanks for anyhelp,

      Br, FireFox.