Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help (Not Homework)

  1. Feb 6, 2008 #1
    I Need This Solved Please


    public class harness {
    public static void main(String[] args) {
    int[][] key = {{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

    int direction = 1;
    int[] primes = {2,3,5,7,11,13,17,19};
    String plainString = new String("I PUT THE TEXT IN HERE");
    char[] plainCharArray = plainString.toCharArray();
    int[] plainIntArray = new int[plainCharArray.length];
    int[] cipherIntArray = new int[plainCharArray.length];
    char[] cipherCharArray = new char[plainCharArray.length];
    for(int x =0; x<plainIntArray.length; x++)
    plainIntArray[x] = (int)plainCharArray[x] -97;
    for(int x = 0; x < plainIntArray.length; x++){
    int k = 0;
    for(int y = 0; y <8; y++){
    k+= key[y][x%primes[y]] %26;
    cipherIntArray[x] = (plainIntArray[x] +direction*k +260)%26;
    for(int x =0; x< cipherIntArray.length; x++)
    cipherCharArray[x] = (char)(cipherIntArray[x] +97);
    String myString = new String(cipherCharArray);


    for decription you enter the ciphertext at the same place, and you set direction to -1
    the key is that matrix, the 1's are spots that can be entered, and the spots that are 0 do not change
    by the way, everything is lowercase and there are no spaces
    here is what is generated by encrypting my message to you guys:


    This Isnt Homework Ive Done School
  2. jcsd
  3. Feb 6, 2008 #2


    User Avatar

    Staff: Mentor

    It's not clear what you are asking for. And even if it isn't homework or coursework, you need to show some effort toward the solution that you are asking for.
  4. Feb 6, 2008 #3
    Yes I Understand What This Site Is About I Think This Was Covered In School By Some1

    I Just Didnt Do This Course

    So I Figured What Might Be Hard For Me Would Be Easy For You?

    I Honestly Cannot Tell You What Attempts Ive Tried

    When I Feel Like Im Getting Close To An Answer It Just Slips Away :(
  5. Feb 7, 2008 #4


    User Avatar
    Science Advisor
    Homework Helper

    It might be easy for us, but I can't tell what you're trying to do. Can you explain?
  6. Feb 9, 2008 #5
    Its Programming..

    This Is A Psysic's Forum Thats Y No Help :D

    Sry Guys
  7. Feb 10, 2008 #6

    jim mcnamara

    User Avatar

    Staff: Mentor

    I am a programmer. The code above is not even remotely valid code, with static void main() embedded inside a public class. For starters.

    What are your expected inputs and outputs? Since you know programming, you also know that you surround code with code tags on a website, or nobody can read it.

    Fix your code then do not tell us how YOU want to solve it programmatically. Tell us what you expect input and outputs to be. We'll be glad to help.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook