Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 27th, 2009, 04:29 PM
Registered User
Join Date: Oct 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crypto question

I'm taking my first programming class, and we're using java. I've been getting the hang of everything so far, but functions are starting to leave me in the dust I think. I'm currently working on a project that is supposed to encrypt or decrypt a phrase, and I'm stuck.

I'm not sure how to convert a phrase the user inputs from the 'key' string (correct alphabet) to my 'alpha' string (jumbled alphabet). Can anyone help me out?

Here is the program so far:

import java.util.*;

public class Crypto {

  static Scanner input = new Scanner(System.in);
  public static void main(String[] args) {
    boolean keepGoing = true;

      String response = menu();

        if (response.equals("1")){
          System.out.println("Please enter unencrypted phrase");
          String plain = input.nextLine();
          plain = plain.toUpperCase();

        } else if (response.equals("2")){
          System.out.println("Please enter encrypted phrase");
          String code = input.nextLine();
          code = code.toUpperCase();

        } else if (response.equals("0")){
          keepGoing = false;

        } else {
          System.out.println("Sorry. I didn't understand");
        } // end if
      } // end while
   } // end main    
  public static String menu(){
	  System.out.println("Crypto Machine");
	  System.out.println("Please enter a selection.");
	  System.out.println("0) Quit");
	  System.out.println("1) Encrypt a phrase.");
	  System.out.println("2) Decrypt a phrase.");
	  String result = input.nextLine();
	  return result;
  } //end menu
  public static String decrypt(){
  } //end decrypt

  public static String encrypt(){

  } //end encrypt
} // end Crypto
Reply With Quote
  #2 (permalink)  
Old November 1st, 2009, 01:07 AM
Friend of Wrox
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post

check the following links, they have couple of examples, might give you a start

- Rakesh
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disappearing UserName & Question within Customized PasswordRecovery Question Template eddiemcham ASP.NET 3.5 Basics 13 June 13th, 2009 04:23 AM
Need Help with C# Crypto Classes chobo2 ASP.NET 3.5 Basics 0 March 23rd, 2009 01:50 PM
How to figure out blockSize from a Crypto Key chobo2 C# 2008 aka C# 3.0 0 November 13th, 2008 12:52 AM
Missing Crypto algorithm Stephen Lam All Other Wrox Books 0 May 22nd, 2005 09:10 PM
Crypto problems pilmart Pro VB 6 0 June 10th, 2004 09:40 AM

All times are GMT -4. The time now is 11:38 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.