# VBForums UtilityBank > UtilityBank - Tutorials >  Tutorial - Rot13/Rot-N Encryption

## prophecy

*- |Rot13/Rot-N Encryption Tutorial| -*   

_What is Rot13 encryption?_
    Rot13 simple means rotating alphabet by 13 characters. It is a very primitive encryption method which can be easily decrypted on knowledge. But for a non-technical user it still remains an unsolved mystery. Rot13 encryption is very easy to understand and use. It is very similar to the Caesar-Encryption method. Here what we do is rotate the character backwards or front by 13 characters in the ASCII table. The means "a" becomes "n" and "p" becomes "}". This method has been used in many news delivery systems as to prevent third parties from gaining easy access to it in the past. But now there are many better encryption systems being used which remain hard to be decrypted. Rot13 uses very simple algorithms and the encryption/decryption functions can be easily made.

_What is Rot-N encryption?_
    Rot13 and Rot-N are very similar with the only exception that Rot-N encryption rotates each character by any number of digit rather than 13. It is basically a number between 1 to 25 so it remains within the ASCII table.

_Here is a simple visual basic function for encrypting/decrypting a string:- _  
    Rot-13 was basically made only for typed characters and not any extra signs or special characters so trying characters like "?ot; would cause the program to fail. Anyways you can modify the function to fit all special characters too.

*Visual Basic Functions:*

VB Code:
Public Function encrypt(strInput As String)
    Dim n As Integer, i As Integer
    n = 13
    For i = 1 To Len(strInput)
        Mid(strInput, i, 1) = Chr(Asc(Mid(strInput, i, 1)) + n)
    Next i
    encrypt = strInput
End Function

VB Code:
Public Function decrypt(strInput As String)
    Dim n As Integer, i As Integer
    n = 13
    For i = 1 To Len(strInput)
        Mid(strInput, i, 1) = Chr(Asc(Mid(strInput, i, 1)) - n)
    Next i
    decrypt = strInput
End Function

The variable *n* specifies the number of characters with which it rotates.
Variable *i* is used to loop through each character and then rotate it *n* characters forward or backward.

    To increase the strength of the encryption, you can further tweak the code a bit like reversing the string or converting every alternate character to Ucase and using numbers to enhance encryption.

    Here is a sample program I made in Visual Basic 6 that clearly explains this method of encryption. 


Download Now [Exe + Source Code]


- Written By,
- Dayson Pais 
- www.compzone.hhnf.com




> Authors Name: Dayson Pais
> Description: Rot13/Rot-N Encryption Tutorial
> Level: Beginners
> License info: Tutorial is Copyright Protected © CompZone.hhnf.com
> The code can be used and modified by anyone. I shall not be held responsible for any reflected offense.

----------


## si_the_geek

The code/files within this thread (submitted: 6-17-2005) have been checked for malware by a moderator.

Disclaimer: _This does not necessarily mean that any compiled files (DLL/EXE/OCX etc) are completely safe, but any supplied code does not contain any obvious malware.  It also does not imply that code is error free, or that it performs exactly as described.

It is recommended that you manually check any code before running it, and/or use an automated tool such as Source Search by Minnow (available here or here).  
If you find any serious issues (ie: the code causes damage or some sort), please contact a moderator of this forum.

Usage of any code/software posted on this forum is at your own risk._

----------


## Bhj777

Can you post the .vbproj file for this program? I run Visual Basic 2010 and your source files don't open in it. Please upload the .vbproj file for it. You can email it to me at: bharadwaj.raju777@gmail.com. Also, how did you make those 2-way text boxes? I just can't seem to figure it out. By the way, awesome program!

Thanks

----------

