roto13

  • Thread starter Thread starter basil
  • Start date Start date
B

basil

Hello
Is their a macro around that well do roto13 code?
thanks
Basil
 
PS: if you Google for this use ROT13 not ROTO13
best wishes
 
It's pretty simple


Public Function encrypt(pInput As String)
Dim n As Integer
Dim i As Integer

n = 13
For i = 1 To Len(pInput)
Mid(pInput, i, 1) = Chr(Asc(Mid(pInput, i, 1)) + n)
Next i
encrypt = pInput

End Function

Public Function decrypt(pInput As String)
Dim n As Integer
Dim i As Integer

n = 13
For i = 1 To Len(pInput)
Mid(pInput, i, 1) = Chr(Asc(Mid(pInput, i, 1)) - n)
Next i
decrypt = pInput

End Function



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Thank you Bob
I will try this also
Basil
Bob Phillips said:
It's pretty simple


Public Function encrypt(pInput As String)
Dim n As Integer
Dim i As Integer

n = 13
For i = 1 To Len(pInput)
Mid(pInput, i, 1) = Chr(Asc(Mid(pInput, i, 1)) + n)
Next i
encrypt = pInput

End Function

Public Function decrypt(pInput As String)
Dim n As Integer
Dim i As Integer

n = 13
For i = 1 To Len(pInput)
Mid(pInput, i, 1) = Chr(Asc(Mid(pInput, i, 1)) - n)
Next i
decrypt = pInput

End Function



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

filout web page form 2
change pivot table in code 3
Basil Brush 5
pdf writer check 3
Macro 3
Duplicate all of the rows in a worksheet 5
Avoid asking to open with macros 6
Cycle through a list 4

Back
Top