How Can I Improve My Encryption Code?

  • Thread starter Thread starter kkissofdeath
  • Start date Start date
  • Tags Tags
    Homework
Click For Summary

Discussion Overview

The discussion revolves around improving a provided encryption code. Participants engage with the code's structure, functionality, and the user's request for assistance, which is framed as a programming challenge rather than a homework problem.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • The user presents a Java code snippet intended for encryption but does not clarify the specific issues they are facing.
  • Some participants express confusion about the user's request and emphasize the need for clearer communication regarding expected inputs and outputs.
  • One participant critiques the code's validity, pointing out structural issues such as the placement of the main method within the class.
  • Another participant suggests that the user should demonstrate effort in solving the problem before seeking help.
  • The user acknowledges a lack of understanding and expresses frustration with their attempts to solve the problem.

Areas of Agreement / Disagreement

Participants generally agree that the user's request lacks clarity and that the code has significant issues. However, there is no consensus on how to proceed with helping the user without more information about their expectations.

Contextual Notes

The discussion highlights limitations in the user's explanation of their problem, including missing details about the expected functionality of the code and the nature of the errors encountered.

Who May Find This Useful

Individuals interested in programming, particularly in encryption algorithms, and those looking for community support in debugging code may find this discussion relevant.

kkissofdeath
Messages
3
Reaction score
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
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.
 
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 :(
 
It might be easy for us, but I can't tell what you're trying to do. Can you explain?
 
Its Programming..

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

Sry Guys
 
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.
 

Similar threads

Replies
4
Views
5K
Replies
55
Views
7K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 89 ·
3
Replies
89
Views
6K