Sunday, May 12, 2013

Simple asterisk filter function for strings

Took a bit of thinking to achieve this. This function processes a given string and tells whether it is in agreement with the provided filter input. It accepts the wildcard filter character, asterisk(*) only.
It returns TRUE if the given 'name' parameter is compatible with the provided 'filter' parameter.

Private Function FilterCompliant(ByVal name As String, ByVal filter As String) As Boolean
'//Author : s0ft
'//Contact : aayush.babu@yahoo.com
'//Blog : http://www.c0dew0rth.blogspot.com
'//Usage : Returns TRUE if the given 'name' string is compliant with the given 'filter'
'//it is crucial to understand the working of the asterisk * wildcard character to make a function that processes it
filter = LCase$(filter)
name = LCase$(name)
If filter = "*" Then
    FilterCompliant = True
    Exit Function
End If
Dim splitparts() As String
splitparts = Split(filter, "*")
If splitparts(0) = "" Then splitparts(0) = Left$(name, 1) '//if filter starts with * like e.g *gr*q then make splitparts(0) which would otherwise be "" the first letter of the name
nextstart = 1 '//tells from where to start looking for between-the-asterisk-characters in filter var
For i = 0 To UBound(splitparts)
If Left$(filter, InStr(filter, "*") - 1) = Left$(name, InStr(filter, "*") - 1) Then '//whether *sth or go*sth, the first character(s)-before-asterisk must be the same in filter and name var. So this is a necessary condition
    If InStr(nextstart, name, splitparts(i)) <> 0 Then '//search from nextstart position the string splitparts(i) in name var
        nextstart = InStr(nextstart, name, splitparts(i)) + Len(splitparts(i)) '//so that next time instr wont count the same letter
        cnt = cnt + 1
    Else
        Exit For
    End If
End If
Next i
If cnt = UBound(splitparts) + 1 Then '//necessary condition
    If Right$(filter, 1) = "*" Then '//if filter is in format:  hehe*
        FilterCompliant = True
    ElseIf StrReverse(Left$(StrReverse(filter), InStr(StrReverse(filter), "*") - 1)) = Right$(name, InStr(StrReverse(filter), "*") - 1) Then '//if input is in format: comp*r then give YES to only those words with the same after-final-asterisk-character(s)
        FilterCompliant = True
    End If
End If
End Function



Usage example:

Private Sub Form_Load()
Debug.Print FilterCompliant("eloquent", "*oq*")
End Sub
 

Sunday, November 25, 2012

Basic Rar Password Recovery

This is a rudimentary RAR password cracker I tried making about three days ago. Working off and on, I managed to put some decent, respectable features into it. I had started with it thinking it would be something entertaining and educative to just fool around with, but in a very short span of time, I found myself building it better and more practical, so I decided it should be given a chance and thus tidied up the GUI, did some brain tickling for new functions that could be added to it and implemented those possible.
Despite all my efforts, however, it's still the work of a single individual, of a few days and things may have been left untested and bugs undiscovered. So, if you would like to use it, use it at your own risk and if you get any flaw(s) in the program, a report on it would always be welcome.
Download here

Sunday, August 12, 2012

Len and Trim alternatives

From some alternative vb functions, these two are my most recent ones.

Option Explicit

Private Function newlen1(ByVal str As String) As Long
'//Author : s0ft(aayush.babu@yahoo.com)
'//Web    : c0dew0rth.blogspot.com
'//May 27, 9 : 03 PM
If str = "" Then newlen1 = 0: Exit Function
Dim cnt As Long
cnt = 0 '//you may or may not include this line
Dim char As String
Do
    char = Mid$(str, 1, cnt + 1)
    If char <> "" Then
        cnt = cnt + 1
    End If
Loop Until str = char
newlen1 = cnt
End Function

Function AltLen2(ByVal sString As String) As Long
    Dim bArr() As Byte

    If sString = vbNullString Then Exit Function
    bArr = sString

    AltLen2 = ((UBound(bArr) + 1) / 2)
End Function

Function replacespace(ByVal mainchar As String) As String
'//Author : s0ft(aayush.babu@yahoo.com)
'//Web    : c0dew0rth.blogspot.com
'//A simple Replace$(somestring, " ", "") replacement
Dim bt() As Byte
bt = mainchar
Dim cnt As Long
For cnt = 0 To UBound(bt) Step 2 '//step 2 is here for avoiding the null that appears after every character when converted to byte array
    If bt(cnt) <> 32 Then '//32 DEC is ascii code for space
        replacespace = replacespace + Chr$(bt(cnt)) '//only non space characters will be appended to alttrim
    End If
Next cnt
End Function


Function AltTrim(ByVal char As String) As String
'//Author : s0ft(aayush.babu@yahoo.com)
'//Web    : c0dew0rth.blogspot.com
'//A Trim$(somestring) alternative
Dim bt() As Byte
bt = char
Dim cnt As Long
Dim i As Long
Dim Acc As Long
Dim determined As String
Dim addflag As Boolean
For cnt = 0 To UBound(bt) Step 2
    If bt(cnt) <> 32 Or addflag = True Then
        AltTrim = AltTrim + determined + Chr$(bt(cnt))
    End If
    If AltTrim <> "" Then '//if the first non space character has been found then
        Dim cnt_ As Long
        Acc = 0 '//initialise the counter for number of spaces
        For cnt_ = (cnt + 2) To UBound(bt) Step 2 '//start processing from the next character
            If bt(cnt_) = 32 Then '//if next character is space again,
                Acc = Acc + 1 '//acc will have the number of spaces found. it's just a counter
                addflag = False '//till now a non space character isn't detected so keep the addflag false
            Else '//if next character is not a space then
                determined = Space$(Acc) '//reaching here at any point in this loop will mean the no. of spaces as reported by acc are followed by a non-space character
                addflag = True '//tell the above statements to add the spaces
                cnt = cnt + Acc * 2 '//tell that we're going forward only from the new non-space character
                Exit For  '//skip the loop as we've found one non-space character after Acc number of spaces. Goto skiploop will do the same thing
            End If
        Next cnt_
'//skiploop: '//remove the comment if u use Goto skiploop instead of Exit For above
    End If
Next cnt
End Function

Private Sub Form_Load()
Debug.Print AltTrim("   c a   t      ")
End Sub
 

Sunday, May 27, 2012

DesktopHide

Simple application to enable/disable, show/hide the desktop (with the taskbar) with a specified combination of keys used as passwords.
Download here

Wednesday, May 16, 2012

ProcessSnapshot

Just a simple program that makes logs of the currently running processes combined with other features which could make it a little more useful like logging in a fixed interval of time, for a number of times etc.

 Download here

Saturday, April 14, 2012

AnimateWindow

A program that makes your application's window come into appearance by fading in.
Download here

s0ftSpread 3

Just a version 3 of s0ftspread.
Additional features :
-Yahoo status update (once every run)
-Download once option (only the first time run)
Download here