Results 1 to 5 of 5

Thread: Encryption~

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Location
    Singapore
    Posts
    2

    Unhappy 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???

  2. #2
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    For Caesar:

    VB Code:
    1. Option Explicit On
    2.  
    3. Public Class Caesar
    4.  
    5.     Private Const intDefaultShift As Integer = 3
    6.     Private Const DefaultDirection As ShiftType = ShiftType.Right
    7.  
    8.     Public Enum ShiftType
    9.         Right
    10.         Left
    11.     End Enum
    12.  
    13.     Public Shared Function Encrypt(ByVal strPlainText As String, _
    14.             Optional ByVal Direction As ShiftType = DefaultDirection, _
    15.             Optional ByVal intShiftValue As Integer = intDefaultShift) As String
    16.         Dim strResult As String
    17.  
    18.         Dim intShift As Integer
    19.         If Direction = ShiftType.Left Then
    20.             intShift = -intShiftValue
    21.         Else
    22.             intShift = intShiftValue
    23.         End If
    24.  
    25.         For I As Integer = 1 To strPlainText.Length
    26.             strResult &= Chr(Asc(Mid(strPlainText, I, 1)) + intShift)
    27.         Next
    28.  
    29.         Return strResult
    30.     End Function
    31.  
    32.     Public Shared Function Decrypt(ByVal strCipherText As String, _
    33.             Optional ByVal Direction As ShiftType = DefaultDirection, _
    34.             Optional ByVal intShiftValue As Integer = intDefaultShift) As String
    35.  
    36.         Dim strResult As String
    37.  
    38.         Dim intShift As Integer
    39.         If Direction = ShiftType.Left Then
    40.             intShift = -intShiftValue
    41.         Else
    42.             intShift = intShiftValue
    43.         End If
    44.  
    45.         For I As Integer = 1 To strCipherText.Length
    46.             strResult &= Chr(Asc(Mid(strCipherText, I, 1)) - intShift)
    47.         Next
    48.  
    49.         Return strResult
    50.     End Function
    51.  
    52. End Class

    Note: This isnt entirely like the orginal Cipher, it will Shift any character 0-255

    Usage:

    VB Code:
    1. 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

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Location
    Singapore
    Posts
    2
    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!!

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    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 .

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    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
  •  



Click Here to Expand Forum to Full Width