Sign in to follow this  
Followers 0
ezzetabi

Password based Rotate.

2 posts in this topic

$sT = 'If they make mistakes, lets follow them! (Remainder lesson)'
$sPass = 'a pass!'

MsgBox(16,'', _Rot($st, $sPass, 0))
MsgBox(16,'', _Rot($st, $sPass, 1))

Func _Rot(ByRef $sInput, $sPass, $bMode)
  Local $sChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'
  Local $iNofC = StringLen($sChars)
  Local $c, $iPos, $sChr
  Local $ipl = StringLen($sPass)
  Local $isl = StringLen($sInput)
  Local $aiPass[$ipl]
  
  For $c = 0 to $ipl - 1
    $aiPass[$c] = Asc(StringMid($sPass, $c + 1, 1)) + 17
  Next
  $sPass = 0
  For $c = 1 to $isl
    $sChr = StringMid($sInput, $c, 1)
    $iPos = StringInStr($sChars, $sChr, 1)
    If $iPos > 0 Then
      If $bMode = 0 Then
        $sChr = StringMid($sChars, _Mod($aiPass[Mod($c - 1, $ipl)] + $iPos, $iNofC), 1)
      Else
        $sChr = StringMid($sChars, _Mod(- $aiPass[Mod($c - 1, $ipl)] + $iPos, $iNofC), 1)
      EndIf
    EndIf
    
    
    $sInput = StringLeft($sInput, $c - 1) & $sChr & StringTrimLeft($sInput, $c)
  Next
  
  Return $sInput
EndFunc

Func _Mod($iDividend, $iDivisor)
  Local $iMod
  If $iDivisor <> 0 Then
    If $iDividend < 0 Then
      $iDividend = $iDividend * -1
      $iMod = Mod($iDividend, $iDivisor)
      
      if $iMod = 0 Then
        Return $iMod
      Else
        Return $iDivisor - $iMod
      EndIf
    EndIf
    
    Return Mod($iDividend, $iDivisor)
  Else
    SetError(1)
    Return '-1.#IND'
  EndIf
EndFunc
Exit

Share this post


Link to post
Share on other sites



Nice code, works great.

Cheers.. :)

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