Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. Encryption/Decryption of a text, image and folder

Encryption/Decryption of a text, image and folder

Scheduled Pinned Locked Moved Visual Studio
questioncsharpsecurity
9 Posts 4 Posters 18 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 13514321
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • U User 13514321

      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

      S Offline
      S Offline
      Sascha Lefevre
      wrote on last edited by
      #2

      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

      U 1 Reply Last reply
      0
      • S Sascha Lefevre

        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

        U Offline
        U Offline
        User 13514321
        wrote on last edited by
        #3

        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

        L U 2 Replies Last reply
        0
        • U User 13514321

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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?

          U 1 Reply Last reply
          0
          • L Lost User

            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?

            U Offline
            U Offline
            User 13514321
            wrote on last edited by
            #5

            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

            L S 2 Replies Last reply
            0
            • U User 13514321

              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

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              java encryption - Google Search[^].

              U 1 Reply Last reply
              0
              • L Lost User

                java encryption - Google Search[^].

                U Offline
                U Offline
                User 13514321
                wrote on last edited by
                #7

                nvm thanks

                1 Reply Last reply
                0
                • U User 13514321

                  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

                  S Offline
                  S Offline
                  Sascha Lefevre
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • U User 13514321

                    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

                    U Offline
                    U Offline
                    User 13541037
                    wrote on last edited by
                    #9

                    Nice post

                    Applock apk is the best application for locking the screen and Applications in Your android mobils.

                    1. FingerPrint App Lock
                    2. Gesture App Lock
                    3. Applock APk
                    4. App Lock APK

                    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

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups