How Can I Improve My Encryption Code?

  • Thread starter kkissofdeath
  • Start date
  • Tags
    Homework
In summary: I Need This Solved PleaseIn summary, the programmer is asking for help with code that is not valid. They ask for inputs and outputs, but do not provide them. They say that they are a programmer, but do not provide any code that would back this up. They ask for help, but do not provide any information about what is wrong with their code.
  • #1
kkissofdeath
3
0
I Need This Solved Please




Code

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},
{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};

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);
System.out.println(myString);


}
}


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:

charsxrowtrvizrrcvnlcftgdkhhnafgewhefszmfdwvqmvujqflkpapjwwhobliliodhlawtkkjwgzzhdzcqqxuywfwuhvaultavvemlfvmvoewlpqsjybrlrpdtnluyixodgahozgiswirvvikyhmeacnxhxpcfefptagvukxzumqlpshprzfsjrgvhjqmijbqrehcnavwalyuyxfluvvayseqmkaalvzkyvpflfxafywgcmhlfeaykncgguvlttziuwwjapupyublggnkygaasam






This Isnt Homework I've Done School
 
Technology news on Phys.org
  • #2
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.
 
  • #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 I've Tried

When I Feel Like I am Getting Close To An Answer It Just Slips Away :(
 
  • #4
It might be easy for us, but I can't tell what you're trying to do. Can you explain?
 
  • #5
Its Programming..

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

Sry Guys
 
  • #6
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.
 

1. What is "Help (Not Homework)"?

"Help (Not Homework)" is a program designed to provide academic assistance and support to students in a way that promotes learning and understanding, rather than simply completing homework assignments.

2. How does "Help (Not Homework)" differ from traditional homework help?

Unlike traditional homework help, "Help (Not Homework)" focuses on helping students develop critical thinking and problem-solving skills, rather than simply giving them the answers. This allows students to better understand the material and become more independent learners.

3. Who can benefit from "Help (Not Homework)"?

"Help (Not Homework)" can benefit students of all ages and academic levels. It is particularly helpful for students who struggle with certain subjects or have difficulty completing homework assignments on their own.

4. How does "Help (Not Homework)" work?

Students can attend "Help (Not Homework)" sessions, where they will work with a tutor or mentor who will guide them through problem-solving techniques and provide support and guidance as needed. Students can also access resources and materials outside of the sessions to further enhance their learning experience.

5. Is "Help (Not Homework)" only for students who are struggling academically?

No, "Help (Not Homework)" is not only for struggling students. It can also benefit high-achieving students who want to deepen their understanding of a subject and improve their critical thinking skills.

Similar threads

  • Programming and Computer Science
Replies
3
Views
888
Replies
1
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
0
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Programming and Computer Science
Replies
2
Views
3K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
2
Views
3K
Back
Top