Wrox Programmer Forums
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
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
Old November 1st, 2009, 01:07 AM
Friend of Wrox
Join Date: Mar 2007
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

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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.