RC4 TextFile Encrypter!
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
9 posts
Page 1 of 1
What you need:
1 open file dialog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 save file dialog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 text box's:
Textbox 1 needs to be read only!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 buttons:
Button 1 is called select file and goes
by textbox 1
Button 2 is called encrypt file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 label
RC4 Password and goes by textbox 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Imports:
An old friend of mine for helping me: 90%
Me: 10%
cooll;
1 open file dialog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 save file dialog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 text box's:
Textbox 1 needs to be read only!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 buttons:
Button 1 is called select file and goes
by textbox 1
Button 2 is called encrypt file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 label
RC4 Password and goes by textbox 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Imports:
Code: Select all
The whole code from start to end after import copy and paste!
Imports System.IO
Imports System.Text
Code: Select all
Credits:Public Class Form1
Dim filereadin, fileout As String
Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
Dim i As Integer = 0
Dim j As Integer = 0
Dim cipher As New StringBuilder
Dim returnCipher As String = String.Empty
Dim sbox As Integer() = New Integer(256) {}
Dim key As Integer() = New Integer(256) {}
Dim intLength As Integer = password.Length
Dim a As Integer = 0
While a <= 255
Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0))
key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp)
sbox(a) = a
System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
End While
Dim x As Integer = 0
Dim b As Integer = 0
While b <= 255
x = (x + sbox(b) + key(b)) Mod 256
Dim tempSwap As Integer = sbox(b)
sbox(b) = sbox(x)
sbox(x) = tempSwap
System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1)
End While
a = 1
While a <= message.Length
Dim itmp As Integer = 0
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
itmp = sbox(i)
sbox(i) = sbox(j)
sbox(j) = itmp
Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256)
Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0)
itmp = Asc(ctmp)
Dim cipherby As Integer = itmp Xor k
cipher.Append(Chr(cipherby))
System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
End While
returnCipher = cipher.ToString
cipher.Length = 0
Return returnCipher
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
TextBox1.Text = OpenFileDialog1.FileName
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Text = "" Then
MessageBox.Show("Pick A File!", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
If TextBox2.Text = "" Then
MessageBox.Show("Pick A Password", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
FileOpen(1, TextBox1.Text, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
filereadin = Space(LOF(1))
FileGet(1, filereadin)
FileClose(1)
SaveFileDialog1.ShowDialog()
Try
fileout = SaveFileDialog1.FileName
FileOpen(1, fileout, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
FilePut(1, rc4(filereadin, TextBox2.Text))
FileClose(1)
TextBox1.Text = ""
MessageBox.Show(fileout & " Was created!", "Done", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Catch ex As Exception
End Try
End Sub
End Class
An old friend of mine for helping me: 90%
Me: 10%
cooll;
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
so is the password gonna be saved in the same file as the orginal file or will there be a separate file with the password.
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Seperate thats why the save file dialog is there 

<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
pip wrote:Seperate thats why the save file dialog is there
so what will happen if someone delete that file.
can you still access your rc4 file without it
or do i understand it a little wrong?
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
its whatever yo utype password or text it encrypts in file it really is back up but encrypted
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
o cool 
thanks pip

thanks pip

visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
+rep for this <3! I searched for this a long long time!!!
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
Hey Pip
What i would really like is to be able to DECrypt the Encrypted file back to it's original state.... It would make a great little addition to an app i am working on, where you could send someone a encrypted file and as long as they have the Decrypter app and Password to the Encrypted file, they could then turn the file back to it's original state..
Just a Thought
Chris
What i would really like is to be able to DECrypt the Encrypted file back to it's original state.... It would make a great little addition to an app i am working on, where you could send someone a encrypted file and as long as they have the Decrypter app and Password to the Encrypted file, they could then turn the file back to it's original state..
Just a Thought
Chris
#hungryhounduk A bit lazy to try, but here is a supposed idea this code that creates it:
Code: Select all
You need to take this : FilePut(1, rc4(filereadin, TextBox2.Text)) and whatever hash or encrypted thing try to make a function that reverses the encryption and just make it do this:
Try
fileout = SaveFileDialog1.FileName
FileOpen(1, fileout, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
FilePut(1, rc4(filereadin, TextBox2.Text))
FileClose(1)
TextBox1.Text = ""
MessageBox.Show(fileout & " Was created!", "Done", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Catch ex As Exception
End Try
Code: Select all
so prob some stuff to select were file is and a textbox for entering the pass like one of shims apps, and maybe another string.FilePut(1, rc4(filereadin, EncryptedTextBox2.Text))
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
9 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023