|
-
Jul 27th, 2004, 03:43 AM
#1
Thread Starter
New Member
Encryption~
hello~ i'm having this project that need me to encrypt a plain text~ i gotta use transposition cipher using 6 digit key followed by 6 characters shifted right using caesar cipher... i've been cracking my head for it a very long time already and i couldnt figure it out... could someone just help me with it???
-
Jul 27th, 2004, 07:12 AM
#2
For Caesar:
VB Code:
Option Explicit On
Public Class Caesar
Private Const intDefaultShift As Integer = 3
Private Const DefaultDirection As ShiftType = ShiftType.Right
Public Enum ShiftType
Right
Left
End Enum
Public Shared Function Encrypt(ByVal strPlainText As String, _
Optional ByVal Direction As ShiftType = DefaultDirection, _
Optional ByVal intShiftValue As Integer = intDefaultShift) As String
Dim strResult As String
Dim intShift As Integer
If Direction = ShiftType.Left Then
intShift = -intShiftValue
Else
intShift = intShiftValue
End If
For I As Integer = 1 To strPlainText.Length
strResult &= Chr(Asc(Mid(strPlainText, I, 1)) + intShift)
Next
Return strResult
End Function
Public Shared Function Decrypt(ByVal strCipherText As String, _
Optional ByVal Direction As ShiftType = DefaultDirection, _
Optional ByVal intShiftValue As Integer = intDefaultShift) As String
Dim strResult As String
Dim intShift As Integer
If Direction = ShiftType.Left Then
intShift = -intShiftValue
Else
intShift = intShiftValue
End If
For I As Integer = 1 To strCipherText.Length
strResult &= Chr(Asc(Mid(strCipherText, I, 1)) - intShift)
Next
Return strResult
End Function
End Class
Note: This isnt entirely like the orginal Cipher, it will Shift any character 0-255
Usage:
VB Code:
MsgBox(Caesar.Encrypt("I CAME I SAW I CONQUERED", Caesar.ShiftType.Right, 6))
Can you be more explicit about the transposition cipher?
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Jul 27th, 2004, 09:27 AM
#3
Thread Starter
New Member
hiya is the codes for VB.Net? coz i gotta VB.Net for my project~ anyway i gotta thank you for the codes!! i'm not sure how to explain about the transposition cipher thing coz i'm not an expert in VB.Net~ but our class got this project which requires us to use that to encrypt a plain text~ anyway thanks a lot for the caesar cipher codes!!
-
Jul 27th, 2004, 11:08 AM
#4
Its not a wise move to just copy and paste from other people for school projects. I suggest you actually look at and understand what is happening, you will look pretty foolish if your are asked to explain the code. Especially as you dont seem to know what language the code is written in .
-
Jul 27th, 2004, 11:12 AM
#5
wait so as a project for school they told you to write an encryption routine in a language that you dont even know how to program in?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|