mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 Tiny text encryption

Author Message
AMBience

  • Total Posts : 29
  • Scores: 0
  • Reward points : 0
  • Joined: 7/24/2008
  • Status: offline
Tiny text encryption Friday, June 25, 2010 9:07 AM (permalink)
0
This single function will encrypt and decrypt a string using a key. It uses seeded random so there's 2147483647 combinations for the key value (pretty low level). However you can encrypt an already encrypted string multiple times making it even stronger and impossible to crack unless you know the seed number sequence.

I also made it skip quotes in the input and output so you can paste encrypted strings into scripts.  This was a bit of a pain as space is char 32 (and is needed) but quotes are char 34. To get around this I swap it with the tilde (char 126), which you can't use in your string, sorry!

As for the output, try scrambling a string like:- aaaaaaaaaaaaa (looks like any other encrypted word)

 '------------------------------- Scramble -------------------------------'
 ' strText = String to encrypt\decrypt '
 ' lngSeed = Long number for the random seed (key) '
 ' Returns a string '
 
 ' To Encrypt:- Send the plain text with a positive seed number (1-2147483647)'
 ' To Decrypt:- Send the encrypted text with the same number but negative '
 
 Function Scramble (strText, lngSeed)
     Dim L,intRand,bytASC
     Rnd(-1) : Randomize ABS(lngSeed)
     For L = 1 To Len(strText)
         bytASC=Asc(Mid(strText, L))
         If bytASC=126 then bytASC=34
         intRand = bytASC + ((Int(Rnd(1) * 160) - 80) * SGN(lngSeed)) 
         If intRand <= 31 Then 
             intRand = 125 - (31 - intRand)
         ElseIf intRand >= 126 Then
             intRand = 32 + (intRand - 126)
         End If
         If intRand=34 then intRand=126
         Scramble = Scramble & Chr(intRand)
     Next
 End Function
 


Here's the test app I used to write it (with comments).....Just save it as "Whatever.HTA"

 <HTML><HEAD><HTA:APPLICATION /></HEAD>
 <BODY SCROLL="no" STYLE="font-size:16;margin:0px" BGCOLOR="buttonface">
     Seed (1 to 2147483647)<br><INPUT ID="Text4" TYPE="TEXT" SIZE=16 VALUE="1"/><br>
     Text to encrypt<br><INPUT ID="Text1" TYPE="TEXT" SIZE="88" STYLE="Font-Family:Courier new" />
     <INPUT TYPE="button" ID="Button1" VALUE="Encode" /><br>
     Encrypted text<br><INPUT ID="Text2" TYPE="TEXT" SIZE="88" STYLE="Font-Family:Courier new"/>
     <INPUT TYPE="button" ID="Button2" VALUE="Decode" /><br>
     Decrypted text<br><INPUT ID="Text3" TYPE="TEXT" SIZE="88" STYLE="Font-Family:Courier new"/><br>
 </BODY>
 <SCRIPT LANGUAGE="VBScript">
 
 Self.ResizeTo 800,220
 Text3.ReadOnly = true
 
 '---- Encrypted HTA title ----'
 Document.Title = Scramble ("pO25|YBG.C7]Sz~gO% ZwyHeIZne|ayWTM~b9IsG",-2010)
 
 '---- Test encrypt button ----'
 Sub Button1_OnClick()
     Text2.value = Scramble (Text1.value,  Text4.value)
     Text3.value = ""
 End Sub
 
 '---- Test decrypt button ----'
 Sub Button2_OnClick()
     Text3.value = Scramble (Text2.value, -Text4.value)
 End Sub
 
 '---- Scramble ----'
 Function Scramble (strText, lngSeed)
     Dim L,intRand,bytASC
     
     '---- Force seeded random mode 
     Rnd(-1)
     
     '---- Set (positive) seed 
     Randomize ABS(lngSeed)
     
     '---- Scan through string
     For L = 1 To Len(strText)
         
         '---- Get ASC of char
         bytASC=Asc(Mid(strText, L))
         
         '---- Fix for quotes (tilde to quote)
         If bytASC=126 then bytASC=34
         
         '---- Add a random value from -80 to 80, encode\decode is decided by the seed's sign
         intRand = bytASC + ((Int(Rnd(1) * 160) - 80) * SGN(lngSeed)) 
         
         '---- Cycle char between 32 and 125 (with carry)
         If intRand <= 31 Then 
             intRand = 125 - (31 - intRand)
         ElseIf intRand >= 126 Then
             intRand = 32 + (intRand - 126)
         End If
         
         '---- Fix for quotes (quote to tilde)
         If intRand=34 then intRand=126
         
         '---- Output string
         Scramble = Scramble & Chr(intRand)
     Next
 End Function
 
 </SCRIPT>
 </HTML>
 

#1
    TomRiddle

    • Total Posts : 608
    • Scores: 12
    • Reward points : 0
    • Joined: 2/7/2008
    • Location: Australia
    • Status: offline
    Re:Tiny text encryption Sunday, June 27, 2010 1:05 AM (permalink)
    0
    Hey that's not bad dude, did you write it? 
    I added it to my vbscript cipher collection thanks.
     
    Edit - I noticed that it may generate some unprintable characters.
    <message edited by TomRiddle on Sunday, June 27, 2010 1:16 AM>
    -join([int[]][char[]]'Ut|jwXmjqq%Wzqjx'|%{[char]($_-5)})
    #2
      AMBience

      • Total Posts : 29
      • Scores: 0
      • Reward points : 0
      • Joined: 7/24/2008
      • Status: offline
      Re:Tiny text encryption Friday, July 02, 2010 8:38 AM (permalink)
      0
      Thanks Tom!  Yes I did write it.

      Unprintable characters? As in for a printer?  There're in the range of 32-125 so you shouldn't see any square-box fonts?......not sure.  I suppose you could lower it to 32-96 to be extra safe.

      #3
        Hackoo

        • Total Posts : 92
        • Scores: 0
        • Reward points : 0
        • Joined: 6/25/2010
        • Status: offline
        Re:Tiny text encryption Monday, August 09, 2010 3:41 AM (permalink)
        0
        Hi ! Thank you !  this Function is very usefull i used it here in my script in a French Forum : AUTHENTIFICATION WITH YOUR PERSONAL PENDRIVE.
        I will translate it as soon as possible in english and i will post it here in this forum, so be patient
        #4
          Hackoo

          • Total Posts : 92
          • Scores: 0
          • Reward points : 0
          • Joined: 6/25/2010
          • Status: offline
          Re:Tiny text encryption Friday, November 05, 2010 10:56 AM (permalink)
          0
          Hi
          Most people have many files or folders on their computer which they don't want to others see or use them. If you are interested in protecting your personal information, Folder Protection is just what you are searching for. With Folder Protection you will protect your files avoiding them to be being modified, seen or erased by other users.
          You can hide folders simply with a few mouse clicks. Folder Protection is protected by an encrypted password (with this Function Scramble Thanks to AMBience) stored in the registry that you can change or remove it at any time.
          NB:The executable is in French but you can of course modify,translate and compile it in english and you can post your modification here in this Topic ! it's Open Source for all 
          I'm waiting for your testing and your comments 


          Demo in Interactive Video


          Download The Source Code

          <message edited by Hackoo on Friday, November 05, 2010 12:06 PM>
          #5
            alleypuppy

            • Total Posts : 6
            • Scores: 0
            • Reward points : 0
            • Joined: 1/14/2011
            • Status: offline
            Re:Tiny text encryption Friday, February 11, 2011 11:57 AM (permalink)
            0
            Is it possible to change the title of the window?
            #6

              Online Bookmarks Sharing: Share/Bookmark

              Jump to:

              Current active users

              There are 0 members and 1 guests.

              Icon Legend and Permission

              • New Messages
              • No New Messages
              • Hot Topic w/ New Messages
              • Hot Topic w/o New Messages
              • Locked w/ New Messages
              • Locked w/o New Messages
              • Read Message
              • Post New Thread
              • Reply to message
              • Post New Poll
              • Submit Vote
              • Post reward post
              • Delete my own posts
              • Delete my own threads
              • Rate post

              2000-2012 ASPPlayground.NET Forum Version 3.8
              mbt shoes www.wileywilson.com