Jump to content
Sign in to follow this  
Jeep

[UDF] Some more string management routines

Recommended Posts

Here is an other UDF for string handling :

Date handling

_StringDateConvert:  convert a date from one format ("YMD", "MDY" or "DMY") to another.

_StringIsDate:  checks if a date with a given format is valid

String management

_StringCount: count of occurrences that appear in a string

_StringFormatBytesSize: formatting a dimension expressed in bytes (bytes) in MB, TB, ...)

_StringIsEndingWith: check if a string end with some characters

_StringIsStartingWith: check if a string start with some characters

_StringJoinArray:  concatenate elements of an array to rebuild a string

_StringPadLeft: filling a string with characters on the left

_StringPadRight: fill a string with characters on the right

_StringRemoveFrenchAccent: remove french accent

_StringRemoveChars: deleting characters from a string

_StringStrip: eliminate characters at the begin and/or at the  end of a string

_StringTitleCaseFrench: capitalize the first letter of each word with elimination of french accents

_StringWSClean: simple replacement of "White Spaces",  remove beginning and trailing spaces and multiple spaces removal

Any comments, suggestions for improvement or constructive criticism are welcome.

Below you will find the UDF and a demo program. 

 

 

JPD_String.zip

Edited by Jeep
Unvaluable fonction has been removed

Share this post


Link to post
Share on other sites

This is awesome... I like the encryption part... what standard is the encryption method? AES 128, 192 or 256 bits?

Edited by Skeletor

Kind Regards
Skeletor

"I need coffee to turn me back to a human"

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen

Share this post


Link to post
Share on other sites

Dear Skeletor,

Encryption method are one of the method supported by _Crypt_EncryptData (see _Crypt_DeriveKey : creates a key from algorithm and password) :

The constants are defined in "#include <Crypt.au3>"

$CALG_AES_128     128 bits
$CALG_AES_192     192 bits
$CALG_AES_256        256 bits
$CALG_DES     56 bits
$CALG_3DES     168 bits
$CALG_RC2     128 bits
$CALG_RC4     128 bits

You may use these  constants as the value supplied for $iAlgorithm parameter in StringEncrypt and StringDecrypt. The default is $CALG_RC4. Use the same value in the two functions if you would like to receive the correct result :-).

Edited by Jeep

Share this post


Link to post
Share on other sites

Dear Jeep,

So basically your UDF's just point back to the original code.. I see it in you MsgBox ... you just wrapped a Func around it. 
 


Kind Regards
Skeletor

"I need coffee to turn me back to a human"

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen

Share this post


Link to post
Share on other sites

Hello Skeletor, 

That's exactly what the function do: simplify the use of basic function already implemented in AutoIt. I've  spend few hours playing with all the basic Crypt functions and it's my result how to do simply the job.

 

 

Share this post


Link to post
Share on other sites
3 hours ago, Jeep said:

Hello Skeletor, 

That's exactly what the function do: simplify the use of basic function already implemented in AutoIt. 

Care to expand on this? I guess I am wondering at why someone would use your _StringBetween2 function, for example, when there is already a _StringBetween (as noted yourself in your comments). What does your function do that the native function does not? Same with _StringAppend, you take a one-line snippet and expand it into a whole function - is there really a need to pad it like that?

I'm all for new folks learning the language and trying new things, but the Examples forum is intended to be a showcase for "cool scripts". If what you are doing is simply adding another wrapper around an existing function, without significantly changing one of its properties (fewer lines, better error checking, faster run time, etc. etc. etc.) is there really any benefit? And if your functions do meet those criteria you should explain exactly how it does so, so forum members can benefit.


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Colduction
      Hi guys!, i have a problem to convert Python code to AutoIt code, in fact i had not coded with Python yet!, this code is about permutation a string's case, i will be happy with your comments :)❤;

      Python code:
       
      # Python code to print all permutations # with respect to cases # Function to generate permutations def permute(inp): n = len(inp) # Number of permutations is 2^n mx = 1 << n # Converting string to lower case inp = inp.lower() # Using all subsequences and permuting them for i in range(mx): # If j-th bit is set, we convert it to upper case combination = [k for k in inp] for j in range(n): if (((i >> j) & 1) == 1): combination[j] = inp[j].upper() temp = "" # Printing current combination for i in combination: temp += i print(temp), # Driver code permute("Hello") # This code is contributed by Sachin Bisht
      My code in AutoIt:
      ; https://www.geeksforgeeks.org/permute-string-changing-case/ _PermuteCase("ABC") Func _PermuteCase($sText) If StringRegExp($sText, "^[A-Za-z]{1,}$") Then Local $iLength = StringLen($sText) ; Get length of the text. Local $iMaxPerm = 2 ^ $iLength ; Number of permutations is 2^n Local $sLow_Text = StringLower($sText) ; Converting string to lower case Local $asChrs = StringToASCIIArray($sLow_Text) ; Split the text into array of chars. For $i = 1 To $iMaxPerm Step 1 For $j = 0 To $asChrs[0] ;................................................... Next Next Else Return SetError(-1, 0, "Error: Input is incorrect!") EndIf EndFunc ;==>_PermuteCase  
       
       
       
       
       
      ====================== SOLUTION by @TheXman ======================
       
    • By careca
      This is another take on string triggers, triggers on specific strings.
      Able to simple text pasting,
      opening links (as long as there's a www. http:\\ or https:\\ at the beggining)
      and is able to open applications, if there is a parameter in the parameter field, it uses it.
      Shows your external, lan, and gateway ip's.
      Able to change system volume by a set percentage, reading from the inputbox the number the user sets, if 0 or empty uses system default.
      The 4 longer input fields at the bottom, represent the process scaning, the 2 to the left continuously scan for the process name,
      and the 2 to the right are executed when the process in the left is found.
      process 1 for app 1, example, look for notepad.exe and start paint.exe if notepad is found.
      I made this because the existing string trigger applications didn't do it for me.
      I did this for me, but if someone finds it useful all the better.
    • By Colduction
      Hello again to all, I've searched many times in forum and help file to find AES-256-GCM Algorithm for Crypt\Decrypt strings and files but i did not find anything about GCM Algorithm.

      Do you have any idea for solving this issue?
    • By Stormgrade
      Hello.
      I'm french, sorry for my english.
      I release my project, a password manager : Password Keeper
      First I would like to thanks Guinness and Melba23 for their help, and I'm very sorry for those I forget, please remind me to add you.
      Well my program manage and crypt passwords, first I understand if you don't trust me for this kind of sensible software, but I remember you that all the the source files are at your disposal, fell free to explore them.
      The login is : admin and you can change it later
      How it work ? see Methode de cryptage en BDD.pdf in french
      login

       
      The main interface
      You can obviously add,modify and delete your entry, also you can search with keywords

      A password generator is included

      I won't update it anymore.
      It's a BSD license.
      Autoit version : 3.3.14.5
      Have a good day.
      Methode de cryptage en BDD.pdf Passwordkeeper.7z
    • By jmp
      i am trying to get number from string using this code :
      #include <IE.au3> $oIE = _IEAttach ("Edu.corner") Local $aName = "Student name & Code:", $iaName = "0" Local $oTds = _IETagNameGetCollection($oIE, "td") For $oTd In $oTds If $oTd.InnerText = $aName Then $iaName = $oTd.NextElementSibling.InnerText $iGet = StringRegExpReplace($iaName, "\D", "") EndIf Next MsgBox(0, "", $iGet) it was get number like 52503058
      But, I want to get only student code 5250. (Different student have different code, sometime its 3 digits, Sometime 4)

       
×
×
  • Create New...