lStrWildCmpEx() new flags

ot4xb version 1.6.4.81 introducing the new function lStrWildCmpEx() that is an extension of the existing lStrWildCmp()

As the lStrWildCmp() old function the new lStrWildCmpEx() function compare an input string with a template string that can contain wildcards * and ? like the directory wildcards.

The previous function was only supporting the flag 1 or .T. meaning case insensitive compare

lStrWildCmpEx() with the flag 0x200 support C++ 14 stdlib regular expressions ( faster  than the ot4xb rgx class or functions based on the VB Script reg exp)

Another new feature is that we can provide also an array of wildcard strings instead of a single wildcard string


Syntax


lStrWildCmpEx( cWild|aWild , cStr,[nFlags],[regex_flags],[regex_match_flags]) -> lMatch

cWild|aWild
....
cStr
....
nFlags
Can be a combination of zero or more of the following flags
 0x0001 = case insensitive
 0x0002 = return found index ( first or last if flags & 4 )
 0x0004 = stop at first ocurrence
 0x0008 = add * at the begining and end of the wildcard emulating the $ operator (1.6.4.84)
 0x0010 = compare left trimmed string if not using regexp
 0x0020 = compare right trimmed string if not using regexp
 0x0040 = allow ^ at the begining as negation ( 1.6.4.85)
 0x0200 = ot4xb_regex_match
 0x8000 = ( only arrays without regexp) ( 1.6.4.85)
                 if ~ ( char 126) at the begining the expression MUST NOT exist
                 if ` ( char 96) at the begining the expression MUST exist
0x0100 = use template characters ( alphanumeric(A) ,numbers (9)  and symbols )

regex_flags
Only with nFlags & 0x200
ECMAScript = 0x01   ( DEFAULT )
basic = 0x02
extended = 0x04
awk = 0x08
grep = 0x10
egrep = 0x20
_Gmask = 0x3F
icase = 0x0100
nosubs = 0x0200
optimize = 0x0400
collate = 0x0800

regex_match_flags
Only with nFlags & 0x200
match_default = 0x0000,
match_not_bol = 0x0001,
match_not_eol = 0x0002,
match_not_bow = 0x0004,
match_not_eow = 0x0008,
match_any = 0x0010,
match_not_null = 0x0020,
match_continuous = 0x0040,
match_prev_avail = 0x0100,
format_default = 0x0000,
format_sed = 0x0400,
format_no_copy = 0x0800,
format_first_only = 0x1000

ot4xb_cng() new methods for rc4 encryption

ot4xb version 1.6.4.83 introducing 2 new class methods to add RC4 encryption to the ot4xb_cng() class


The previous function was only supporting the flag 1 or .T. meaning case insensitive compare

CLASS ot4xb_cng

The purpose of the ot4xb_cng class is to provide some encryption and decryption methods using the Windows CNG API

Syntax


AES 256 methods
ot4xb_cng():aes_encrypt( cInputStr  , flags) -> cOutputString 

ot4xb_cng():aes_decrypt( cInputStr  , flags ) -> cOutputString 

RC4 methods
ot4xb_cng():rc4_encrypt( cInputStr  , flags ) -> cOutputString 

ot4xb_cng():rc4_decrypt( cInputStr  , flags ) -> cOutputString 

flags
_ot4xb_expando_() object providing the required parameters for the encryption or decryption operations
cInputStr
The string to be encrypted or decrypted. flags:encode_input will determine the expected content
cOutputString
The string resulting from the encryption or decryption operation. flags:encode_input will determine the expected content


common flags

flags:encode_input
supported values are "bin","hex" and "base64" or "b64"
flags:encode_output
supported values are "bin","hex" and "base64" or "b64"
flags:key
key or password phrase used for the encryption or decryption operation
flags:encode_key
supported values are "bin","hex" and "base64" or "b64"


AES 256 specific flags

flags:mode
Suported modes for AES are "ebc" or "cbc"
flags:aes_block_padding
Logical value. default .F.
flags:IV
CBC mode will require a 16 bytes initialization string
flags:encode_IV
supported values are "bin","hex" and "base64" or "b64"

StrTrimEx() with flag 0x200



Working with some existing stuff where I had a method now  like this  to return a yyymmddThh:mm:ss string  that I used in several places of the project I'm working on.

INLINE CLASS METHOD now
local ft := ChrR(0,8)
ft64_now(@ft,.T.)
return ft64_GetTs(ft,'%04.4hu-%02.2hu-%02.2huT%02.2hu:%02.2hu:%02.2hu')


But for the new stuff I needed to put this time string into 2 fields one for the date and another for the time, and have just remembered the flag 0x200 of the old ot4xb StrTrimEx() function, so I can keep only digits and the : for the hour, and was written quick this 2 methods.

INLINE CLASS METHOD ts2date(ts)
return StoD( Left(StrTrimEx( ts , "0123456789:",0x200),8) )


and

INLINE CLASS METHOD ts2time(ts)
return SubStr( StrTrimEx( ts , "0123456789:",0x200),9)

One of this days will post an example for the condense string flags, ....






StrTrimEx()

Syntax


StrTrimEx(cStr,cTrimChars,nFlags,chReplaceForCondenseString) --> cStr_trimmed 

cStr
....
cTrimChars
....
nFlags
      0x01 - Trim characters on the left side of the string

      0x02 - Trim characters on the right side of the string

      0x03 - Trim characters on both sides of the string

      0x100 - Condense String

      0x200 - Remove unsafe ( list is safe unless 0x1000 )

      0x1000 - INVERT TABLE  if 0x200 only then list is unsafe

chReplaceForCondenseString
By default a single space