Encryption/Decryption of a text, image and folder
-
hey hi guys i am pretty new in this, how do i go about creating an encryption / decryption application for text,image and folder in vb.net in one interface? Thanks let me how can i start with it Thanks
-
hey hi guys i am pretty new in this, how do i go about creating an encryption / decryption application for text,image and folder in vb.net in one interface? Thanks let me how can i start with it Thanks
You could start by searching this site for articles on encryption. There are plenty. Then start with encrypting and decrypting a single file, with a console application. Whether the file is text or an image or anything else is completely irrelevant. Encryption methods take byte-streams as input and every file is a byte-stream, basically. Then look into how to enumerate the files contained in a folder and repeat the steps for the single-file-encryption for every file you find in the folder. If all that works, build a GUI for it.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
You could start by searching this site for articles on encryption. There are plenty. Then start with encrypting and decrypting a single file, with a console application. Whether the file is text or an image or anything else is completely irrelevant. Encryption methods take byte-streams as input and every file is a byte-stream, basically. Then look into how to enumerate the files contained in a folder and repeat the steps for the single-file-encryption for every file you find in the folder. If all that works, build a GUI for it.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.FileDialog;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;public class FileEncryption {
protected Shell shell;
private Text text;
private Text text_1;
private Text text_2;
private static Cipher encrypt;
private static Cipher decrypt;private static void encrypt(InputStream input, OutputStream output)
throws IOException {
output = new CipherOutputStream(output, encrypt);
writeBytes(input, output);
}
private static void decrypt(InputStream input, OutputStream output)
throws IOException {
input = new CipherInputStream(input, decrypt);
writeBytes(input, output);
}
private static void writeBytes(InputStream input, OutputStream output)
throws IOException {
byte[] writeBuffer = new byte[512];
int readBytes = 0;
while ((readBytes = input.read(writeBuffer)) >= 0) {
output.write(writeBuffer, 0, readBytes);
}
output.close();
input.close();
}
protected void createContents() {
// prepare the keys and iv
byte[] keyBytes = new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89,
(byte) 0xab, (byte) 0xcd, (byte) 0xef };
byte[] ivBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07 };final SecretKeySpec key = new SecretKeySpec(keyBytes, "DES");
final IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);btnSelectAFile.addSelectionListener(new SelectionAdapter() { //textfile//
@Override
public void widgetSelected(SelectionEvent e) {
try {
final Shell shell = new Shell();
FileDialog dlg = new FileDialog(shell, SWT.OPEN);
String fileName = dlg.open();
if (fileName != null) {
text.setText(fileName);
}
} catch (Exception e1) {
e1.printStackTrace();
} }
});
btnEncrypt.addSelectionListener(new SelectionAdapter() { //encrypyt button//
@Override
public void widgetSelected(SelectionEvent e) {
try {
encrypt = Cipher.getInstance("DES/CBC/PKCS5Padding");
encrypt.init(Cipher.ENCRYPT_MODE, key, ivSpec);
encrypt(new FileInputStream(txtFile.get -
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.FileDialog;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;public class FileEncryption {
protected Shell shell;
private Text text;
private Text text_1;
private Text text_2;
private static Cipher encrypt;
private static Cipher decrypt;private static void encrypt(InputStream input, OutputStream output)
throws IOException {
output = new CipherOutputStream(output, encrypt);
writeBytes(input, output);
}
private static void decrypt(InputStream input, OutputStream output)
throws IOException {
input = new CipherInputStream(input, decrypt);
writeBytes(input, output);
}
private static void writeBytes(InputStream input, OutputStream output)
throws IOException {
byte[] writeBuffer = new byte[512];
int readBytes = 0;
while ((readBytes = input.read(writeBuffer)) >= 0) {
output.write(writeBuffer, 0, readBytes);
}
output.close();
input.close();
}
protected void createContents() {
// prepare the keys and iv
byte[] keyBytes = new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89,
(byte) 0xab, (byte) 0xcd, (byte) 0xef };
byte[] ivBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07 };final SecretKeySpec key = new SecretKeySpec(keyBytes, "DES");
final IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);btnSelectAFile.addSelectionListener(new SelectionAdapter() { //textfile//
@Override
public void widgetSelected(SelectionEvent e) {
try {
final Shell shell = new Shell();
FileDialog dlg = new FileDialog(shell, SWT.OPEN);
String fileName = dlg.open();
if (fileName != null) {
text.setText(fileName);
}
} catch (Exception e1) {
e1.printStackTrace();
} }
});
btnEncrypt.addSelectionListener(new SelectionAdapter() { //encrypyt button//
@Override
public void widgetSelected(SelectionEvent e) {
try {
encrypt = Cipher.getInstance("DES/CBC/PKCS5Padding");
encrypt.init(Cipher.ENCRYPT_MODE, key, ivSpec);
encrypt(new FileInputStream(txtFile.get -
You have posted this in the Visual Studio forum, your initial question refers to VB.NET, but the above code is Java. What exactly are you trying to do?
Hey hi sry I decided to write in Java as I am not able to programme in vb.net, I was wondering if you are able to guide me in java. thanks, Sean
-
Hey hi sry I decided to write in Java as I am not able to programme in vb.net, I was wondering if you are able to guide me in java. thanks, Sean
-
nvm thanks
-
Hey hi sry I decided to write in Java as I am not able to programme in vb.net, I was wondering if you are able to guide me in java. thanks, Sean
You need to ask specific questions. By just posting your source code or asking for "guidance" people don't know what exactly you need help with. If you do have one or more specific questions then post them along with your source code in the Java forum so the Java people will see it.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.FileDialog;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;public class FileEncryption {
protected Shell shell;
private Text text;
private Text text_1;
private Text text_2;
private static Cipher encrypt;
private static Cipher decrypt;private static void encrypt(InputStream input, OutputStream output)
throws IOException {
output = new CipherOutputStream(output, encrypt);
writeBytes(input, output);
}
private static void decrypt(InputStream input, OutputStream output)
throws IOException {
input = new CipherInputStream(input, decrypt);
writeBytes(input, output);
}
private static void writeBytes(InputStream input, OutputStream output)
throws IOException {
byte[] writeBuffer = new byte[512];
int readBytes = 0;
while ((readBytes = input.read(writeBuffer)) >= 0) {
output.write(writeBuffer, 0, readBytes);
}
output.close();
input.close();
}
protected void createContents() {
// prepare the keys and iv
byte[] keyBytes = new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89,
(byte) 0xab, (byte) 0xcd, (byte) 0xef };
byte[] ivBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07 };final SecretKeySpec key = new SecretKeySpec(keyBytes, "DES");
final IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);btnSelectAFile.addSelectionListener(new SelectionAdapter() { //textfile//
@Override
public void widgetSelected(SelectionEvent e) {
try {
final Shell shell = new Shell();
FileDialog dlg = new FileDialog(shell, SWT.OPEN);
String fileName = dlg.open();
if (fileName != null) {
text.setText(fileName);
}
} catch (Exception e1) {
e1.printStackTrace();
} }
});
btnEncrypt.addSelectionListener(new SelectionAdapter() { //encrypyt button//
@Override
public void widgetSelected(SelectionEvent e) {
try {
encrypt = Cipher.getInstance("DES/CBC/PKCS5Padding");
encrypt.init(Cipher.ENCRYPT_MODE, key, ivSpec);
encrypt(new FileInputStream(txtFile.getNice post
Applock apk is the best application for locking the screen and Applications in Your android mobils.
Xcode for windows is an application available for Mac OS. There are a lot of ways to use the Xcode on your Windows operating system.
spy phone is an android application which helps users to spy his family if you have one-time access to their mobile. spy phone App has a lot of features but it is limited because of security reasons.
Snaptube is the best application that is not available in the play store to download videos from the youtube, facebook. snaptube for pc was initially launched in November 2014. Right now Snaptube App is available in popular app stores like Uptodown, 9apps etc. Snaptube is the only application which is available for all the platforms such as Snaptube Apk For Android, Snaptube For Mac, Snaptube PC Download. In this article, we will explain you the unique features and installation method of Snaptube For PC.Snaptube Application is also available for Snaptube For Windows, Snaptube For Mac, Snaptube For Linux, Snaptube Apk For Android.
imo for pc is the latest emerging video calling and chatting app, which will be the best competitor to the social media giant Whatsapp, Facebook, Messenger, Hike, Wechat, etc.Friends the next question arise on all of our minds is How to install IMO for PC?. Yes, of course, it is true. There is a reason behind this to install IMO for Windowsimo for windows.Download Imo for pc
Snaptube for pc is the one of the best video and audio download from Facebook, Instagram, and Dailymotion on your pc windows 7/8/10 and other windows device