ROT_13 Crypter/Decrypter Module
The Module is by me. Here the wikipedia Article: http://en.wikipedia.org/wiki/ROT13
Hatte mal bisschen Freizeit und habe dann das Module geschrieben.
Here the Executeable(Commandline):
http://rapidshare.com/files/294783120/ROT_13.rar
If the String you want to Crypt have Spaces then you need to insert quotes(""). Example:
ROT_13 crypt "Hello World"
Here then Source:
Code:
'
'ROT_13 Crypt/Decrypt Module
'by alexj.
'© 2009
'
'
Module ROT_13
Public Shared Function ROT13(ByVal input As String) As String
Dim bData() As Byte = Encoding.ASCII.GetBytes(input)
Dim bUKey(25) As Byte
Dim bLKey(25) As Byte
For i As Byte = 0 To 25
bUKey(i) = 65 + ((i + 13) Mod 26)
bLKey(i) = 97 + ((i + 13) Mod 26)
Next
For j As Integer = 0 To (bData.Length - 1)
Select Case bData(j)
Case 65 To 91
bData(j) = bUKey(bData(j) - 65)
Case 97 To 122
bData(j) = bLKey(bData(j) - 97)
Case Else
bData(j) = 32 ' space
End Select
Next
Return Encoding.ASCII.GetString(bData)
End Function
End Module
Re: ROT_13 Crypter/Decrypter Module
Re: ROT_13 Crypter/Decrypter Module
You forgot the decrypt
vb Code:
Imports System.Text
Module ROT_13
Public Function Crypt(ByVal input As String) As String
Dim bData() As Byte = Encoding.ASCII.GetBytes(input)
Dim bUKey(25) As Byte
Dim bLKey(25) As Byte
For i As Byte = 0 To 25
bUKey(i) = 65 + ((i + 13) Mod 26)
bLKey(i) = 97 + ((i + 13) Mod 26)
Next
For j As Integer = 0 To (bData.Length - 1)
Select Case bData(j)
Case 65 To 91
bData(j) = bUKey(bData(j) - 65)
Case 97 To 122
bData(j) = bLKey(bData(j) - 97)
Case Else
bData(j) = 32 ' space
End Select
Next
Return Encoding.ASCII.GetString(bData)
End Function
Public Function Decrypt(ByVal ROT_13CryptedText As String) As Object
Dim str As String = String.Empty
Dim str2 As String = ROT_13CryptedText
Dim num As Integer = 0
Dim length As Integer = str2.Length
Do While (num < length)
Dim ch As Char = str2.Chars(num)
Select Case Asc(ch.ToString)
Case 65 To 91
If Asc(ch.ToString) > 77 Then
str = str & Chr(Asc(ch.ToString) - 13).ToString
Else
str = str & Chr(Asc(ch.ToString) + 13).ToString
End If
Case 97 To 122
If Asc(ch.ToString) > 109 Then
str = str & Chr(Asc(ch.ToString) - 13).ToString
Else
str = str & Chr(Asc(ch.ToString) + 13).ToString
End If
Case Else
str = str & " "
End Select
num += 1
Loop
Return str
End Function
End Module
Re: ROT_13 Crypter/Decrypter Module
Quote:
Originally Posted by
gooden
You forgot the decrypt
vb Code:
Imports System.Text
Module ROT_13
Public Function Crypt(ByVal input As String) As String
Dim bData() As Byte = Encoding.ASCII.GetBytes(input)
Dim bUKey(25) As Byte
Dim bLKey(25) As Byte
For i As Byte = 0 To 25
bUKey(i) = 65 + ((i + 13) Mod 26)
bLKey(i) = 97 + ((i + 13) Mod 26)
Next
For j As Integer = 0 To (bData.Length - 1)
Select Case bData(j)
Case 65 To 91
bData(j) = bUKey(bData(j) - 65)
Case 97 To 122
bData(j) = bLKey(bData(j) - 97)
Case Else
bData(j) = 32 ' space
End Select
Next
Return Encoding.ASCII.GetString(bData)
End Function
Public Function Decrypt(ByVal ROT_13CryptedText As String) As Object
Dim str As String = String.Empty
Dim str2 As String = ROT_13CryptedText
Dim num As Integer = 0
Dim length As Integer = str2.Length
Do While (num < length)
Dim ch As Char = str2.Chars(num)
Select Case Asc(ch.ToString)
Case 65 To 91
If Asc(ch.ToString) > 77 Then
str = str & Chr(Asc(ch.ToString) - 13).ToString
Else
str = str & Chr(Asc(ch.ToString) + 13).ToString
End If
Case 97 To 122
If Asc(ch.ToString) > 109 Then
str = str & Chr(Asc(ch.ToString) - 13).ToString
Else
str = str & Chr(Asc(ch.ToString) + 13).ToString
End If
Case Else
str = str & " "
End Select
num += 1
Loop
Return str
End Function
End Module
I didnt Crypting and Decrypting is the same Function ;)
If it crypts A to N and later you use again the Function N is converted to A