Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Good for nothing String Crypter :D filter_list
Author
Message
Good for nothing String Crypter :D #1
This is a silly String Crypter, made by my hobby and study of swing.
https://drive.google.com/file/d/0B8Cwc8L...sp=sharing
What it does: I don't know, it modify the string and recover the string.
Sometimes the string get shorter, sometimes it become longer =)), and it will not work right with the number, already told ya, it is a good-for-nothing program =))
Source:
Spoiler:
import javax.swing.*;
Code:
import java.awt.event.*;

public class Main {
    public static String s;

    private static void createAndShowGUI() {
    JFrame frame = new JFrame("String Crypto");

    JButton inputText = new JButton("Input Text");
    JButton textEncrypt = new JButton("Text Encrypt");
    JButton textDecrypt = new JButton("Text Decrypt");
    JButton showText = new JButton("Show Text");

    inputText.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent ae){
                    s = JOptionPane.showInputDialog(null, "Enter input text : ", null, 1);                    
}});

    textEncrypt.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent ae){
                    String s2 = new String();
                    int cnt = 1;
                    for(int i = 1;i<s.length();i++){
                        if (s.charAt(i) == s.charAt(i-1)){
                            cnt++;
                        }
                        else{
                            s2 += cnt+""+s.charAt(i-1);
                            cnt = 1;
                        };
                        if (i==s.length()-1){
                            s2 += cnt+""+s.charAt(i);
                        };
                    }
                    s = s2;
                    JOptionPane.showMessageDialog(null, "New String: "+s, "StringCrypto",1);
}});
    textDecrypt.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent ae){
                    String s2 = new String();
                    for(int i = 0;i<s.length();i++){
                        if (Character.isDigit(s.charAt(i))){
                            for(int j = Integer.parseInt(s.charAt(i)+"");j>0;j--){
                                s2 += s.charAt(i+1)+"";
                            }
                            
                        };
                    }
                    s = s2;
                    JOptionPane.showMessageDialog(null, "New String: "+s, "StringCrypto",1);
}});

    showText.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent ae){
                    JOptionPane.showMessageDialog(null, "Current String: "+s, "Show String",1);
}});

    JPanel panel = new JPanel();
    panel.add(inputText);
    panel.add(textEncrypt);
    panel.add(textDecrypt);
    panel.add(showText);

        frame.add(panel);
    frame.setSize(400, 400);
    frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

Reply







Users browsing this thread: 1 Guest(s)