Jump to content
Sign in to follow this  
swoop

_StringEncrypt Strange Behavior on Different Computers

Recommended Posts

swoop

I have 7 computers in our office, 6 running Windows 7. One running Windows XP.

The exact same script using _StringEncrypt is compiled and run on these computers.

Two out of the six Windows 7 computers return the same encrypted string, no matter what I enter to the function. The others work fine.

On the Win XP computer, the output string is blank.

This is the oddest behavior I've seen and I just can't figure out what might be wrong. Has anyone else encountered this behavior or something similar to it in AutoIt with the encryption or string functions?

Thanks in advance for any insight!

#include <String.au3>

Func _encryption($input)
Local $base_key,$output
$base_key = "hyuief15"
$output = _StringEncrypt(1,$input,$base_key)
Return $output
EndFunc

Share this post


Link to post
Share on other sites
JScript

On the Win XP computer, the output string is blank.

Your code tested on XP:

Posted Image

#include <String.au3>

Local $input = 'MsgBox(4096, "Title", _encryption($input))'

MsgBox(4096, "Title", _encryption($input))

Func _encryption($input)
    Local $base_key, $output
    $base_key = "hyuief15"
    $output = _StringEncrypt(1, $input, $base_key)
    Return $output
EndFunc   ;==>_encryption

JS

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
dany

On Win 7 64-bit I get the same results as JScript (using his testcase), compiled both 32- and 64-bit. I can't reproduce your problem, sorry...


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites
guinness

_StringEncrypt is outdated, therefore try to use the _Crypt_*** functions. Look at using _Crypt_EncryptData instead.

#include <Constants.au3>
#include <Crypt.au3>

Example()

Func Example()
    ; Encrypt text using a generic password.
    Local $sEncrypted = StringEncrypt(True, 'Encrypt this data.', 'securepassword')

    ; Display the encrypted text.
    MsgBox($MB_SYSTEMMODAL, '', $sEncrypted)

    ; Decrypt the encrypted text using the generic password.
    Local $sDecrypted = StringEncrypt(False, $sEncrypted, 'securepassword')

    ; Display the decrypted text.
    MsgBox($MB_SYSTEMMODAL, '', $sDecrypted)
EndFunc   ;==>Example

Func StringEncrypt($fEncrypt, $sData, $sPassword)
    _Crypt_Startup()
    Local $sReturn = ''
    If $fEncrypt Then
        $sReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_RC4)
    Else
        $sReturn = BinaryToString(_Crypt_DecryptData($sData, $sPassword, $CALG_RC4))
    EndIf
    _Crypt_Shutdown()
    Return $sReturn
EndFunc   ;==>StringEncrypt
Edited by guinness
  • Like 1

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
LWC

I've fixed Binary($sData) to be $sData = Binary($sData).

Also added support for empty values:

 

#include <Crypt.au3>

Example()

Func Example()
    ; Encrypt text using a generic password.
    Local $sEncrypted = StringEncrypt(True, 'Encrypt this data.', 'securepassword')

    ; Display the encrypted text.
    MsgBox(4096, '', $sEncrypted)

    ; Decrypt the encrypted text using the generic password.
    Local $sDecrypted = StringEncrypt(False, $sEncrypted, 'securepassword')

    ; Display the decrypted text.
    MsgBox(4096, '', $sDecrypted)
EndFunc   ;==>Example

Func StringEncrypt($fEncrypt, $sData, $sPassword)
    if $sData="" then
        return $sData
    endif

    _Crypt_Startup()
    Local $sReturn = ''
    If $fEncrypt Then
        $sReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_RC4)
    Else
        If IsString($sData) Then
            $sData = Binary($sData)
        EndIf
        $sReturn = BinaryToString(_Crypt_DecryptData($sData, $sPassword, $CALG_RC4))
    EndIf
    _Crypt_Shutdown()
    Return $sReturn
EndFunc   ;==>StringEncrypt
Edited by LWC

Share this post


Link to post
Share on other sites
guinness

Thanks. But that line isn't really required, hence why the function still worked.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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  

×