Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 rot13

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
IAC249 Posted - May 01 2006 : 11:45:58 AM
Here's a quick rot13 encoder/decoder I wrote in VB. rot13 is good if you want to obfuscate some text, but security isn't a major concern. You can use it to perhaps "translate" some character's speech in a RPG into some strange alien tounge, or to help make private chat more private.

The convert function both encrypts and decrypts the text. There are perhaps more efficient ways of doing this, and if anyone is aware of it, please post the code.

Public Function Convert(stringIn As String) As String
  
    Dim idx As Integer
    Dim ret As String
    Dim ch As String
    Dim chB As Integer
  
    Dim upper() As Variant
    Dim upperROT13() As Variant
  
    Dim lower() As Variant
    Dim lowerROT13() As Variant
  
    If Len(stringIn) > 0 Then
        upper = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")  
        upperROT13 = Array("N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M")  
        lower = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")  
        lowerROT13 = Array("n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m")  
  
        For idx = 1 To Len(stringIn)  
            ch = Mid$(stringIn, idx, 1)  
  
            If ch >= "A" And ch <= "Z" Then
                chB = Asc(ch) - 65  
                ch = upperROT13(chB)  
  
            ElseIf ch >= "a" And ch <= "z" Then
                chB = Asc(ch) - 97  
                ch = lowerROT13(chB)  
  
            End If
  
            ret = ret & ch  
  
        Next idx  
  
    End If
  
    Convert = ret  
  
End Function


Here's the same function ported to REALbasic:

  
  Dim idx As Integer
  Dim ret As String
  Dim ch As String
  Dim chB As Integer
  
  Dim upper() As String
  Dim upperROT13() As String
  
  Dim lower() As String
  Dim lowerROT13() As String
  
  If Len(stringIn) > 0 Then
    upper = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")  
    upperROT13 = Array("N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M")  
    lower = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")  
    lowerROT13 = Array("n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m")  
  
    For idx = 1 To Len(stringIn)  
      ch = Mid(stringIn, idx, 1)  
  
      If StrComp(ch, "A", 0) >  -1  And StrComp(ch, "Z", 0) < 1 Then
        chB = Asc(ch) - 65  
        ch = upperROT13(chB)  
  
      ElseIf StrComp(ch, "A", 0) >  -1 And StrComp(ch, "z", 0) < 1 Then
        chB = Asc(ch) - 97  
        ch = lowerROT13(chB)  
  
      End If
  
      ret = ret + ch  
  
    Next idx  
  
  End If
  
  Return ret  
  

VBGamer © Go To Top Of Page
This page was generated in 0.2 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.