Results 1 to 8 of 8
  1. #1
    Drokechas's Avatar
    Join Date
    May 2014
    Gender
    male
    Location
    In The Shade † ☯ 不可視
    Posts
    407
    Reputation
    23
    Thanks
    2,706
    My Mood
    Drunk

    | EnCryptor & DeCryptor |

    Hello community! .)

    Features:
    - You write any text that you can then encrypt.
    - The encrypted text can of course come back to the original. (DeCrypt)

    Pictures:


    How To?:

    - 2 Buttons
    - 1 TextBox
    - 1 RichTextBox


    Code For Form1.vb:
    Code:
    Public Class Form1
        ' define the local key and vector byte arrays
        Private ReadOnly key() As Byte = _
          {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, _
          15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
        'Private ReadOnly iv() As Byte = {8, 7, 6, 5, 4, 3, 2, 1}
        Private ReadOnly iv() As Byte = {255, 70, 60, 50, 40, 30, 20, 10}
        ' instantiate the class with the arrays
        Private des As New DES(key, iv)
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            RichTextBox1.Text = des.Encrypt(TextBox1.Text)
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            RichTextBox1.Text = des.Decrypt(TextBox1.Text)
        End Sub
    End Class
    2/ Create Class.vb with name: DES.vb

    Put this code:
    Code:
    Imports System****
    Imports System.Text
    Imports System.Security.Cryptography
    Friend Class DES
        ' define the triple des provider
    
        Private m_des As New TripleDESCryptoServiceProvider
    
        ' define the string handler
    
        Private m_utf8 As New UTF8Encoding
    
        ' define the local property arrays
    
        Private m_key() As Byte
        Private m_iv() As Byte
    
        Public Sub New(ByVal key() As Byte, ByVal iv() As Byte)
            Me.m_key = key
            Me.m_iv = iv
        End Sub
    
        Public Function Encrypt(ByVal input() As Byte) As Byte()
            Return Transform(input, m_des.CreateEncryptor(m_key, m_iv))
        End Function
    
        Public Function Decrypt(ByVal input() As Byte) As Byte()
            Return Transform(input, m_des.CreateDecryptor(m_key, m_iv))
        End Function
    
        Public Function Encrypt(ByVal text As String) As String
            Dim input() As Byte = m_utf8.GetBytes(text)
            Dim output() As Byte = Transform(input, _
                            m_des.CreateEncryptor(m_key, m_iv))
            Return Convert.ToBase64String(output)
        End Function
    
        Public Function Decrypt(ByVal text As String) As String
            Try
                Dim input() As Byte = Convert.FromBase64String(text)
                Dim output() As Byte = Transform(input, _
                                 m_des.CreateDecryptor(m_key, m_iv))
                Return m_utf8.GetString(output)
            Catch ex As Exception
                MsgBox("Error, Please check your characters.")
            End Try
    
        End Function
    
        Private Function Transform(ByVal input() As Byte, _
            ByVal CryptoTransform As ICryptoTransform) As Byte()
            ' create the necessary streams
    
            Dim memStream As MemoryStream = New MemoryStream
            Dim cryptStream As CryptoStream = New  _
                CryptoStream(memStream, CryptoTransform, _
                CryptoStreamMode.Write)
            ' transform the bytes as requested
    
            cryptStream.Write(input, 0, input.Length)
            cryptStream.FlushFinalBlock()
            ' Read the memory stream and convert it back into byte array
    
            memStream.Position = 0
            Dim result(CType(memStream.Length - 1, System.Int32)) As Byte
            memStream.Read(result, 0, CType(result.Length, System.Int32))
            ' close and release the streams
    
            memStream.Close()
            cryptStream.Close()
            ' hand back the encrypted buffer
    
            Return result
        End Function
    
    End Class
    Last edited by Drokechas; 05-19-2014 at 03:01 PM.

  2. The Following User Says Thank You to Drokechas For This Useful Post:

    Rebeka (05-19-2014)

  3. #2
    Drokechas's Avatar
    Join Date
    May 2014
    Gender
    male
    Location
    In The Shade † ☯ 不可視
    Posts
    407
    Reputation
    23
    Thanks
    2,706
    My Mood
    Drunk
    In code: Imports System . IO without gap

    Quote Originally Posted by Drokechas View Post

    2/ Create Class.vb with name: DES.vb

    Put this code:
    Code:
    Imports System****
    Imports System.Text
    Imports System.Security.Cryptography
    Friend Class DES
        ' define the triple des provider
    
        Private m_des As New TripleDESCryptoServiceProvider
    
        ' define the string handler
    
        Private m_utf8 As New UTF8Encoding
    
        ' define the local property arrays
    
        Private m_key() As Byte
        Private m_iv() As Byte
    
        Public Sub New(ByVal key() As Byte, ByVal iv() As Byte)
            Me.m_key = key
            Me.m_iv = iv
        End Sub
    
        Public Function Encrypt(ByVal input() As Byte) As Byte()
            Return Transform(input, m_des.CreateEncryptor(m_key, m_iv))
        End Function
    
        Public Function Decrypt(ByVal input() As Byte) As Byte()
            Return Transform(input, m_des.CreateDecryptor(m_key, m_iv))
        End Function
    
        Public Function Encrypt(ByVal text As String) As String
            Dim input() As Byte = m_utf8.GetBytes(text)
            Dim output() As Byte = Transform(input, _
                            m_des.CreateEncryptor(m_key, m_iv))
            Return Convert.ToBase64String(output)
        End Function
    
        Public Function Decrypt(ByVal text As String) As String
            Try
                Dim input() As Byte = Convert.FromBase64String(text)
                Dim output() As Byte = Transform(input, _
                                 m_des.CreateDecryptor(m_key, m_iv))
                Return m_utf8.GetString(output)
            Catch ex As Exception
                MsgBox("Error, Please check your characters.")
            End Try
    
        End Function
    
        Private Function Transform(ByVal input() As Byte, _
            ByVal CryptoTransform As ICryptoTransform) As Byte()
            ' create the necessary streams
    
            Dim memStream As MemoryStream = New MemoryStream
            Dim cryptStream As CryptoStream = New  _
                CryptoStream(memStream, CryptoTransform, _
                CryptoStreamMode.Write)
            ' transform the bytes as requested
    
            cryptStream.Write(input, 0, input.Length)
            cryptStream.FlushFinalBlock()
            ' Read the memory stream and convert it back into byte array
    
            memStream.Position = 0
            Dim result(CType(memStream.Length - 1, System.Int32)) As Byte
            memStream.Read(result, 0, CType(result.Length, System.Int32))
            ' close and release the streams
    
            memStream.Close()
            cryptStream.Close()
            ' hand back the encrypted buffer
    
            Return result
        End Function
    
    End Class
    Donations like thanks .)
    ...





  4. #3
    Lina Yearn's Avatar
    Join Date
    Oct 2012
    Gender
    female
    Location
    Undetected
    Posts
    219
    Reputation
    10
    Thanks
    1,044
    3 errors in DES.vb

  5. #4
    Drokechas's Avatar
    Join Date
    May 2014
    Gender
    male
    Location
    In The Shade † ☯ 不可視
    Posts
    407
    Reputation
    23
    Thanks
    2,706
    My Mood
    Drunk
    Nothing error

    In code: Imports System . IO without gap ? you have



    Quote Originally Posted by Lina Yearn View Post
    3 errors in DES.vb
    Donations like thanks .)
    ...





  6. #5
    MetrikForce's Avatar
    Join Date
    Dec 2013
    Gender
    male
    Posts
    49
    Reputation
    10
    Thanks
    46
    My Mood
    Grumpy
    This isn't "encryption" moreso than it is a "cipher". Also, not sure why anyone's having errors. Your source works fine.

    Quote Originally Posted by Grizzly View Post
    Anything is allowed if you're brave enough.

  7. #6
    Drokechas's Avatar
    Join Date
    May 2014
    Gender
    male
    Location
    In The Shade † ☯ 不可視
    Posts
    407
    Reputation
    23
    Thanks
    2,706
    My Mood
    Drunk
    Not cipher dude..

    Also crypt(UNT TEXT STRING)
    Quote Originally Posted by MetrikForce View Post
    This isn't "encryption" moreso than it is a "cipher". Also, not sure why anyone's having errors. Your source works fine.
    Donations like thanks .)
    ...





  8. #7
    MetrikForce's Avatar
    Join Date
    Dec 2013
    Gender
    male
    Posts
    49
    Reputation
    10
    Thanks
    46
    My Mood
    Grumpy
    Quote Originally Posted by Drokechas View Post
    Not cipher dude..

    Also crypt(UNT TEXT STRING)
    Sorry if how I said that was wrong. It is encryption, however to be specific it'd be a cipher.

    In cryptography, a cipher (or cypher) is an algorithm for performing encryption

    Quote Originally Posted by Grizzly View Post
    Anything is allowed if you're brave enough.

  9. #8
    Drokechas's Avatar
    Join Date
    May 2014
    Gender
    male
    Location
    In The Shade † ☯ 不可視
    Posts
    407
    Reputation
    23
    Thanks
    2,706
    My Mood
    Drunk
    oh okay...

    Quote Originally Posted by MetrikForce View Post
    Sorry if how I said that was wrong. It is encryption, however to be specific it'd be a cipher.
    Donations like thanks .)
    ...





Similar Threads

  1. ROSeik's EnCryptOr & DeCryptOr [[MUUUSSTTTT DDOOOOWWWNNNLLOOAADDD]]
    By steveroseik in forum CrossFire Spammers, Injectors and Multi Tools
    Replies: 9
    Last Post: 03-20-2013, 08:37 AM
  2. [Release] Encryptor/Decryptor by -Away
    By Lyoto Machida in forum Visual Basic Programming
    Replies: 10
    Last Post: 03-12-2011, 03:43 PM
  3. Replies: 10
    Last Post: 07-21-2009, 10:48 PM
  4. AMP Energy Drink Coupon - Free 4 PK of AMP
    By I Am Cornholio in forum General
    Replies: 6
    Last Post: 07-13-2009, 09:00 PM