Encoding A Message Using Caesar Shift

Feb 9, 2014

I have an assignment, similar to ones of seen in the past. The assignment is to take a users text input and to encrypt it using 3 different types of encryptions: Caesar, Transpose, and Reverser. The professor gave us the bulk of the code, and more specifically how to tokenize and shift the letters using Caeser shift. The problem im coming across is that it is not showing anything past the users input. After running it, it just stays there running without showing anything.

Cipher:

package cipher;
import java.util.Scanner;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
public abstract class Cipher {
public String message;
StringBuilder encrypted_message, decrypted_message;

[Code] ....

The constants have their own separate class, and they appear to work fine. I know that the Transpose and Reverser are incomplete, hence them commented out. But if i cant finish with Caeser first, it wont work at all.

View Replies


ADVERTISEMENT

Caesar Cipher - Encode / Decode Message With Given Key

Nov 1, 2014

I have been assigned to make a program that encodes and decodes a given message with the given key (spaced numbers, for example: 3 1 7 4 2 5). I'll post the code for all the classes that I am using below.

QueueInterface:

import java.util.*;
public interface QueueInterface<T>
{
T dequeue() throws QueueUnderflowException;
boolean isEmpty();

[Code] ....

Ok, so the classes to focus on are these:

CircularLinkedUnbndQueue
CircularLinkedQueueITD
Encoder
Decoder
EncodeDecodeConsole
EncodeDecodeITD

Because those are the ones I had to write myself, the others were given to us to use. As far as these classes go, they work fine without causing any errors from the input I give. For example if I enter a message and a key, it correctly encodes and decodes the message with the given key. What I'd like for you fine programmers to do is give feedback on those 6 classes. Like, suggestions on how to make them better or more efficient, neater, changing any of the methods to make them more efficient or prevent any errors beforehand, etc.

View Replies View Related

How To Change Number In Caesar Cipher

Jan 28, 2015

I'm building casar cipher with using ASCII. I'm done changing lower and upper case alphabet, but I don't know how to fix my code for changing number 9 to <.

here is my class code.

public class SimpleMessageCipher implements MessageCipher {
public String encode(String plainText,int shiftKey){
String cipherText="";
for(int i=0;i<plainText.length();i++)
{
//stores ascii value of character in the string at index 'i'
int c=plainText.charAt(i);

[Code]...

View Replies View Related

Result Of Encoded Message Cannot Restore To Original Message By Decoder

Sep 28, 2014

The problem is the result of encoded message can't not restore to the original message by the decoder. Here are my three class's code

SecureMsgMain:

package securemsg.core;
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
 import securemsg.database.*;
 public class SecureMsgMain {
 
[Code] .....

View Replies View Related

Make Simple Caesar Cipher That Takes In String As First Argument

Jan 21, 2014

I'm trying to make a simple Caesar cipher that takes in a String as the first argument and a integer shift as the second argument. Namely, there appears to be a problem with the loop and how I have declared the array - I want the converted characters to be put into a new array called newCharacterArray, converted back to a String and displayed in the command prompt window.

public class Caesar {
public static void main(String inString, int k) {
System.out.println("String: " + inString);
char inStringArray[] = inString.toCharArray();

[code]....

View Replies View Related

Encoding Circuits For App

Nov 12, 2014

I'm having trouble hard-coding exercises into a Circuit for a Java App. I am using JFrame forms to do so. I am using the NetBeans program.

View Replies View Related

Rotate Left Bitwise Shift?

May 13, 2014

I'm trying to replicate the rol(rotate left) instruction in assembly though can only get as far as shifting the bits with '<<' or doing Long.rotateLeft(var, 5). Both of these method don't wrap around the bits as the rol instruction does.

View Replies View Related

How To Make Shift Encoder / Decoder

Oct 16, 2014

I am working on a project where we need to make a shift encoder/decoder. Right now I am working on my prepareString method, and I have no way of testing it yet. I was just wondering if I wrote it correctly. It should pull in the user entered string and check if each character is a letter, and remove all that are not. Then it should turn all the letters to upper case. Based on that does this look right?

private String prepareString(String plainText)
{
int strLength = plainText.length();
for(int i = 0; i < strLength; i++)
{
char c1 = plainText.charAt(i);
boolean isLetter = Character.isAlphabetic(c1);
if(isLetter == false)

[Code]...

View Replies View Related

Servlets :: URL Encoding And Decoding

Jan 29, 2015

I need to encode the URL in order to prevent XSS security threat. I don't have to encode the complete URL, I just have to encode the values for query string. How to encode only the values of query string parameters and change it in the URL itself using java. I am planning to do this in a filter.

View Replies View Related

How To Read XML Tag Without Encoding In Java

Nov 16, 2014

How to read xml tag <br/> without encoding in java. After encoding it becomes <br>. I dont want to encode it. I already tried CDATA[ and StringEscapeUtils.unescapeXml and StringEscapeUtils.unescapeHtml, but unable to change the decode it.

View Replies View Related

Character Encoding Error

Mar 14, 2014

import java.io.*;
public class Q2{
public static void main (String[] args) throws IOException,
ClassNotFoundException

[code]....

For this program, i successfully did create an output.txt, but i have some weird characters in front of "hello" when i open it in notepad or wordpad.

View Replies View Related

How To Create A New Line Feed Character In SHIFT JIS File

Aug 29, 2014

NewLine.PNG

I need creating the end of line character on line 2 of the attached image.

When I try with

and

I get the end of line symbol on line 1. I tried converting ASCII 10 to a character and putting that in the file, but I still get the end of line symbol on line one.

I'm using Sakura as the text editor.

View Replies View Related

JSP :: Best Way To Retrieve Thousand Rows From Database For Encoding?

Mar 6, 2015

I have to create a webpage such that there is an 'import' and 'save' button.

When the user clicks import button, it will retrieve inventories under PRODUCTS table which contains product title, SRP and Sold by (input field) under his account. Average possible returned rows will be around 1k-5k. If the 'Sold By' has value, it will show as read only. But if not, it will be editable.

Then the user has a list of product IDS printed on a paper that was sold by his employees and he has to scan each product id and put the name of his employee under Sold By and the price sold. This is a manual procedure..

Then after he finishes encoding, he has to click save button to save changes in the db.

what is the best way to implement this? Is it efficient to use js functions such as datatables?

View Replies View Related

Character Encoding - Constants For Max Values Of ASCII And UTF-8

Mar 22, 2014

This is my program.

public class C4
{
// instance variables - replace the example below with your own
public static void main(String[] args)
{
System.out.println((char)41);
}
}

I wanted to check that the integer 41 is 'A' in UTF-8, although it's ')' in UTF-16 , so I ran the program with javac -encoding UTF-8 C4.java but the result was still ')'.

How do i fix this? Also, do constants for the max values of ASCII and UTF-8 exist in Java? I need to show how many number of bits are used to represent characters in both encodings.

View Replies View Related

Encoder - Possibility Of Shift Being Larger Than Alphabet Array Length

Apr 20, 2015

I have an encoder that will shift the character of a string X places. Im trying to account for the possibility of the shift being larger than alphabet array length. I've come up with the following, but I still get an ArrayIndexOutOfBounds Error and it never gets past the if statement.

private String encryption(char charArrayElement) {
String [] alphabet = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L",
"M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
String str = String.valueOf(charArrayElement);

[Code] ....

View Replies View Related

Shift-left Array Values - How To Assign Divisors Indexes To Start

Dec 16, 2014

I am writing a program for a game. It is between the user and a virtual player. The game starts with a pool of consecutive integers 1-100. The size of the pool is based on a random generated number at the beginning of the game. At the start, both players' scores are 0. For each turn, the player picks one number from the pool. That value is added to the player's score, the computer gets the sum of all the remaining numbers in the pool that divide evenly into the player's pick. The player's pick and its divisors are then removed from the pool.

The player should be able to play the game as many times as she wants without ending the program. Instructions should appear on the screen only once at the start of the program.

For each turn, both players' current score, the current pool of numbers, and a prompt for a number to be entered should show onscreen. I have written the code until I get to the function that updates the pool of numbers after a turn.

import java.util.Scanner;
import java.util.Random;
public class SlickPick {
public static void main (String[] args){
Scanner read = new Scanner(System.in);
int []pool = new int[100];

[Code] ....

My thinking is that I need to use the binary search to find the indexes of the divisors array and then use those indexes as the start values. I'm not sure how to assign the divisors indexes to start. Do I need an array for start? Whenever I run the program, the only value missing is 3.

//Name : poolUpdate
//Description : This function modifies the contents of the pool as a result of a turn of play.
//Parameters : The pool array, the divisors array, the size, and the user's pick.
// :
//Return :
public static void poolUpdate(int[] pool, int[] divisors, int size, int pick){
int low=0;
int high=size-1;

[Code] ....

View Replies View Related

Instant Message GUI

Mar 14, 2014

import java.awt.*;
import javax.swing.*;
public class InstantMessageFrame extends JFrame
{
private JList friends;
private JTextField message;
private JButton send;

[code]...

1. Open the source code file of your InstantMessageFrame class from Lab 12.2.

2. Add the following three fields to the InstantMessageFrame class: a JTextField named message, a JList named friends, and a JButton named send.

3. Add a method to your InstantMessageFrame class named getMessagePanel()that returns a JPanel and has no parameters. (This method will create a JPanel that will appear in the south border of your JFrame. It will contain a text field in which a message can be entered and a button that sends an instant message to all the friends in the list.)

4. Within getMessagePanel(), instantiate a new JPanel and give it BorderLayout.Assign a message equal to a new JTextField by using the no-argument constructor of JTextField. Assign send to a new JButton,passing in "Send" to the constructor. (This will be the label on the button.)

5. Within getMessagePanel(), add the message text field to the center of the JPanel and add the send button to the east border of the JPanel. The panel is now ready, so return the JPanel reference.

6. Add a method to your InstantMessageFrame class named get-FriendsPane() that returns a JScrollPane and has no parameters.(This method will create a scrollable list that will contain the names of others that you can chat with.)

7. Within getFriendsPane(), assign friends to a new JList by using theno-argument constructor of JList.

8. Within getFriendsPane(), instantiate a new JScrollPane using the following statement: JScrollPane pane = new JScrollPane(friends);

9. The scroll pane is ready, so return the reference pane at the end of getFriendsPane().

10. Within the constructor of InstantMessageFrame, invoke getMessagePanel(),placing the returned panel in the south border of the content pane of InstantMessageFrame.An Introduction to GUI Programming 399

11. Within the constructor of InstantMessageFrame, invoke get-FriendsPane(), placing the returned scroll pane in the center of the content pane of InstantMessageFrame.

12. Save, compile, and run the InstantMessageFrame class.Your InstantMessageFrame now has three visible components: a JList,a JTextField, and a JButton.

View Replies View Related

Error Message Debug

Mar 11, 2014

I'm very new to java code I'm currently learning about loops I've tried to write this for a statement in the program I'm making but its not working. I keep getting this message

LoanQualifier.java:26: error: illegal start of expression
if (salary >0||<=250000)
^
LoanQualifier.java:28: error: illegal start of type
if (yearsOnJob >0||<50)

I'm using Jgrasp for a complier

View Replies View Related

Socket Should Only Read One Message

Apr 4, 2015

if i send messages as in the code below, is there a way to read only one message, if the client doesn't know how long it is (or if he only knows the maximum length)?in the documentation it says, that the method read(byte[]) reads until no data ist available or end of file is decteted. What does the latter mean? Can i extend the array that i sent by a byte that signals the end? Here is my Code:

Server

public class Server implements Runnable{
 ServerSocket server;
HashMap<Short,Socket> clients;
 public Server(){
clients = new HashMap<>();

[code]....

Both are startet in seperate threads. At the moment the first output of the client is "12 bytes read", and then continously "-1 bytes read"(because the server closes).

View Replies View Related

EJB / EE :: How To Pass XML File As Message In JMS

Apr 22, 2014

I am new to the JMS technology. I have written one sample sender and receiver program to pass a string message to the JMS queue and retrieve it back. It is working fine as well. But now, I want to pass a xml file to the JMS queue. Then from there I need to read the XML file and convert it into a Java object Using Jaxb. I know how to convert an XML into java object using Jaxb. But i am unable to send the XML file as a jms message to the listener.

View Replies View Related

How To Send A Message To A Client

Jan 22, 2015

I want to send a message to a specific client in a server. This is my code and what I tried(I have only given you 3 classes in which I believe I have the problem).

TextClient:
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class TextClient {
public TextClient() {

[Code]...

View Replies View Related

JSF :: Message Resource Bundle

Sep 17, 2014

Im debugging a code that has the following setting:

<application>
<message-bundle>com.web.resources</message-bundle>
<locale-config>
<default-locale>en_US</default-locale>
<supported-locale>fr_FR</supported-locale>
</locale-config>
<resource-bundle>
<base-name>com.web.resources.message</base-name>
<var>message</var>
</resource-bundle>
</application>

Just want to ask, for example I have message_en_US.properties and message_en_SG.properties.And the web is currently using the SG property but one property is not exist on it, can I just redirect to use the US property?

View Replies View Related

EJB / EE :: Program To Post Message To IBM MQ

Oct 16, 2014

I wrote stand alone program to post message to IBM MQ , not sure if it posted to queue i see these Another 2,102 character(s) omitted is that mean it didnt post complete message? do i have to increase capacity of text size

JMS Message class: jms_text
JMSType: null
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:414d512042454c4b2e4d49462e514d47ad662c5420128a02
JMSTimestamp: 1413500135480

[Code]...

View Replies View Related

How To Split A String Message

Nov 11, 2014

String path = "/AUTOSAR/Os_0?type=EcucModuleConfigurationValues";
String path1[] = path.split("?type");

I want to split string in such a way that I should get the content before "?" in an another variable. I tried various way but some how I am not getting expected behavior.

View Replies View Related

Multiple Message Boxes

Jun 4, 2015

In vb.Net, when I do the code msgbox("hello world") and put it in a loop, it will execute that command and show a new messagebox for every time the code goes through the loop. I am wanting to do something similar with java but I'm afraid I don't know how.I know that the following code will display a messagebox as I am describing it

Java Code:

JOptionPane.showMessageDialog(null, "message", "title", 1); mh_sh_highlight_all('java');

But when put in a loop, it does two things:

1) It hangs the program

2) It will only display the first message box and when you press ok, the other message boxes will be disregarded and not displayed (I'm assuming because of the hang).

View Replies View Related

Servlets :: Error Message To JSP

Jan 6, 2015

I have a servlet that adds entries to a table and when there is a duplicate it redirects to an error page and I'd like to make it display the duplicate entry id.The problem is when I try to get the parameter and show the error (the duplicate entry id) on my jsp error page it shows null instead of the appropriate number.this is my servlet:

package package_ergasia;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved