Thread: roto13
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Bill Renaud Bill Renaud is offline
external usenet poster
 
Posts: 417
Default roto13

It may also be ROT135. In other words, letters ("A".."Z" and "a".."z") are
rotated 13 character positions, and digits are rotated 5 positions.

Digit Becomes
1 6
2 7

etc.

I have a template that I use to do this that has the following function:

'----------------------------------------------------------------------
'ROT135 encodes/decodes text that has been encoded using the ROT135
algorithm.
'Letters "A" thru "M" rotate down the alphabet to become "N" thru "Z" (13
places).
'Letters "N" thru "Z" rotate back around (wrap around) to "A" thru "M".
'Digits rotate 5 places, so that "0" thru "4" become "5" thru "9",
'and digits "5" thru "9" become "0" thru "4".
'If the input argument Text is a number, the encoded/decoded version
'is returned as a string. Use the VALUE worksheet function on the return
'value of ROT135 if a numerical result is needed.

Public Function ROT135(Text As String) As String
Dim strBuffer As String
Dim lngTextLength As Long
Dim lngIndex As Long
Dim strCharacter As String

lngTextLength = Len(Text)
strBuffer = ""

If lngTextLength 0 _
Then
'Check and convert each character.
For lngIndex = 1 To lngTextLength
strCharacter = Mid$(Text, lngIndex, 1)

Select Case strCharacter
'Rotate letters 13 places.
Case "A" To "M", "a" To "m"
strBuffer = strBuffer & Chr$(Asc(strCharacter) + 13)
Case "N" To "Z", "n" To "z"
strBuffer = strBuffer & Chr$(Asc(strCharacter) - 13)

'Rotate digits 5 places.
Case "0" To "4"
strBuffer = strBuffer & Chr$(Asc(strCharacter) + 5)
Case "5" To "9"
strBuffer = strBuffer & Chr$(Asc(strCharacter) - 5)

'Character is a punctuation symbol; skip the conversion.
Case Else
strBuffer = strBuffer & strCharacter
End Select
Next lngIndex
End If

ROT135 = strBuffer
End Function

--
Regards,
Bill Renaud