Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

ROT13 Encryption

ROT13 Encryption


ROT13 replaces each letter by its partner 13 characters further along the alphabet. For example, HELLO becomes URYYB (or, reversing, URYYB becomes HELLO again).

Source Code:
Quote:Public Class Form1

Dim Letter() As String = {"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", "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"}
Dim Letter2() As String = {"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", "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"}
Dim str As String
Private Sub EncryptButton_Click(sender As Object, e As EventArgs) Handles EncryptButton.Click
str = TextToEncryptTextBox.Text
TextToEncryptTextBox.Clear()
For i As Integer = 0 To str.Length - 1
For j As Integer = 0 To 51
If str(i) = Letter(j) Then
TextToEncryptTextBox.Text = TextToEncryptTextBox.Text + Letter2(j)
GoTo Line1
End If
Next
TextToEncryptTextBox.Text = TextToEncryptTextBox.Text + str(i)
Line1:
Next
End Sub
End Class
So that's what you were trying to do...
So it's a Caesar cipher. Cool little tool that I suppose can be edited.
(May 11, 2015 09:15 PM)Tonight Wrote:  If I get banned for harassment you guys better fix Orchid's diet before you help him fix his computer
You could do something like this too:

PHP Code

<?php 
Private Shared Sub Main(args As String())
    
Console.WriteLine(ROT("Hello", 13))
    
Console.ReadLine()
End Sub

Public Shared Function ROT(input As String, rotation As Integer) As String
    Dim output 
As New StringBuilder()

    For 
Each chr As Char In input
        
If Char.IsLetter(chr) Then
            Dim upper 
As Boolean = Char.IsUpper(chr)

            
Dim rot__1 As Integer = Char.ToLower(chr) + rotation
            Dim min 
As Integer = 97, max As Integer = 122

            
While rot__1 < min
                rot__1 
+= 26
            End 
While
            While 
rot__1 > max
                rot__1 
-= 26
            End 
While

            
output.Append(If(upper, Char.ToUpper(CChar(rot__1)), CChar(rot__1)))
        Else
            
output.Append(chr)
        
End If
    
Next

    
Return output.ToString()
End Function 

I used a code converter
Skype: happy.cbb
0x38E6A0912657E
That's basically a Caesar Shift with a shiftkey of 13.
A little hint:
If you want to improve it you can directly use the ascii-table to
figure out the next chars and not rely on a list of chars. :)
[C#/C++/Asm Coder]
Reverse Engineering / .Net security
This is encoding not encryption...
[Image: vjPWhyy.gif]
Thank you guys for everything!

(May 15, 2015 05:39 AM)Hiiro Wrote:  You could do something like this too:

PHP Code

<?php 
Private Shared Sub Main(args As String())
    
Console.WriteLine(ROT("Hello", 13))
    
Console.ReadLine()
End Sub

Public Shared Function ROT(input As String, rotation As Integer) As String
    Dim output 
As New StringBuilder()

    For 
Each chr As Char In input
        
If Char.IsLetter(chr) Then
            Dim upper 
As Boolean = Char.IsUpper(chr)

            
Dim rot__1 As Integer = Char.ToLower(chr) + rotation
            Dim min 
As Integer = 97, max As Integer = 122

            
While rot__1 < min
                rot__1 
+= 26
            End 
While
            While 
rot__1 > max
                rot__1 
-= 26
            End 
While

            
output.Append(If(upper, Char.ToUpper(CChar(rot__1)), CChar(rot__1)))
        Else
            
output.Append(chr)
        
End If
    
Next

    
Return output.ToString()
End Function 

I used a code converter

That's a good code thx, it's for generally ROT not just ROT13! ✌

(May 15, 2015 05:41 AM)GhostCode Wrote:  That's basically a Caesar Shift with a shiftkey of 13.
A little hint:
If you want to improve it you can directly use the ascii-table to
figure out the next chars and not rely on a list of chars. :)

Thanks, i will go search about ascii-table! :)

(May 15, 2015 11:32 AM)$lick Wrote:  This is encoding not encryption...

Can you please explain what is the difference between them?
(May 15, 2015 11:53 AM)Neos07 Wrote:  Thank you guys for everything!


That's a good code thx, it's for generally ROT not just ROT13! ✌


Thanks, i will go search about ascii-table! :)


Can you please explain what is the difference between them?

https://danielmiessler.com/study/encodin...n_hashing/
[Image: vjPWhyy.gif]
(May 15, 2015 12:22 PM)$lick Wrote:  https://danielmiessler.com/study/encodin...n_hashing/

Yes, you are right, it's encoding.
One-liner for the lolz
Spoiler (Click to View)

Good work tho.
Edit: Wtf, this thread is old.
Lotta blood to let, peace to make, give a fuk about a check
(Apr 3, 2016 04:38 AM)BahNahNah Wrote:  One-liner for the lolz
Spoiler (Click to View)

Good work tho.
Edit: Wtf, this thread is old.
It should be only one function for encoding that is in the same time decoding cuz:
f(f(x)) = x
(Apr 3, 2016 04:51 AM)Neos07 Wrote:  It should be only one function for encoding that is in the same time decoding cuz:
f(f(x)) = x

What? 😶
You need two functions.
Lotta blood to let, peace to make, give a fuk about a check
(Apr 3, 2016 05:02 AM)BahNahNah Wrote:  What? 😶
You need two functions.

ROT13 is an exception because it only needs one function of encoding/decoding and that because the number of letters is 26 so when yrou rotate the letter "A" it will become "N" and if you rotate "N" it will rebecome back to "A" (that's only in case of ROT13).
[Image: o49Nofn.png]
This is fun to see, i busy with something like this :( :P
Good work man and thanks for the share
(Apr 3, 2016 05:06 AM)Neos07 Wrote:  ROT13 is an exception because it only needs one function of encoding/decoding and that because the number of letters is 26 so when yrou rotate the letter "A" it will become "N" and if you rotate "N" it will rebecome back to "A" (that's only in case of ROT13).

So it cant keep the character case or support numbers? 😑

Heres my spin:
Spoiler (Click to View)
Lotta blood to let, peace to make, give a fuk about a check


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by SkofosAug 10, 2019 04:01 PM 3 205 Aug 10, 2019 04:01 PM
Last Post: MavenGradle
[C#] by gigajewAug 5, 2017 02:31 PM 10 559 Aug 5, 2017 02:31 PM
Last Post: Ninja
[Shell] by ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™Jun 9, 2017 08:24 AM 12 486 Jun 9, 2017 08:24 AM
Last Post: 41phafr34k