daily pastebin goal
3%
SHARE
TWEET

C_cipher

Ali-S0 Mar 13th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import javax.swing.*;
  3. import java.util.Scanner;
  4. import java.awt.GridLayout;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.lang.String;
  8. public class Cipher {
  9.     static String tmp = "";
  10.     public static void main(String[] args) {
  11.         JFrame f = new JFrame();
  12.         f.setLayout(new GridLayout(4, 1));
  13.         JTextField txt = new JTextField();
  14.         JTextField txt2 = new JTextField();
  15.         JLabel lbl = new JLabel();
  16.         JLabel lbl2 = new JLabel();
  17.         JButton btn = new JButton("Submit");
  18.         f.add(txt);
  19.         f.add(txt2);
  20.         f.add(lbl);
  21.         f.add(lbl2);
  22.         f.add(btn);
  23.        
  24.         btn.addActionListener(new ActionListener() {
  25.             @Override
  26.             public void actionPerformed(ActionEvent arg0) {
  27.                 // TODO Auto-generated method stub
  28.                 char[] alp = txt.getText().toCharArray();
  29.                 int len = Integer.parseInt(txt2.getText());
  30.                 for(int i = 0; i < alp.length; i++) {
  31.                     alp[i] = (char)((int)alp[i] + len);
  32.                     tmp = tmp + alp[i];
  33.                 }
  34.                 lbl.setText(tmp);
  35.                 //''''''''''''''''''''''''''''''''''''''''''''''''''''//
  36.                 tmp = "";
  37.                 char[] dec = lbl.getText().toCharArray();
  38.                 for(int i = 0; i < dec.length; i++) {
  39.                     dec[i] = (char)((int)dec[i] - len);
  40.                     tmp = tmp + dec[i];
  41.                 }
  42.                 lbl2.setText(tmp);
  43.             }
  44.         });
  45.         f.setVisible(true);
  46.     }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top