Results 1 to 3 of 3

Thread: Tutorial - Rot13/Rot-N Encryption

Threaded View

  1. #1

    Thread Starter
    Addicted Member prophecy's Avatar
    Join Date
    Mar 2005
    Location
    In the developers list of Visual Basic ;-)
    Posts
    242

    Tutorial - Rot13/Rot-N Encryption

    - |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:
    1. Public Function encrypt(strInput As String)
    2.     Dim n As Integer, i As Integer
    3.     n = 13
    4.     For i = 1 To Len(strInput)
    5.         Mid(strInput, i, 1) = Chr(Asc(Mid(strInput, i, 1)) + n)
    6.     Next i
    7.     encrypt = strInput
    8. End Function
    VB Code:
    1. Public Function decrypt(strInput As String)
    2.     Dim n As Integer, i As Integer
    3.     n = 13
    4.     For i = 1 To Len(strInput)
    5.         Mid(strInput, i, 1) = Chr(Asc(Mid(strInput, i, 1)) - n)
    6.     Next i
    7.     decrypt = strInput
    8. 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.
    Attached Files Attached Files
    Last edited by si_the_geek; Jun 19th, 2005 at 04:35 PM. Reason: changed Title format

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width