Jump to content

  • Log In with Google      Sign In   
  • Create Account

ThinkingsHard

Member Since 11 Sep 2012
Offline Last Active Jun 16 2014 04:22 AM

Posts I've Made

In Topic: Beale Cipher

11 May 2014 - 06:17 PM

I fixed it by using this code

	public  void encrypt2(String str, String key)
	{

		for (int i = 0; i <  str.length();  i++) 
		{
			char baelleCh = str.charAt(i);
			char ch = key.charAt(i % key.length());
			// allows spaces
			if(baelleCh == ' ')
			{
				cryptedString2 += baelleCh;    
			}
			else
			{		
				// like the Ceasar Cipher, takes the char in the string, minus 'a' plus the numerical value of the character of the key, mod 26, plus 'a'
				char encoding = (char) (((baelleCh - 'a') + (ch-'a')) % 26 + 'a');
				cryptedString2 += encoding;
			}
		}
	}

In Topic: Beale Cipher

11 May 2014 - 03:51 AM

	public void encrypt2(String str, String key)
	{
		
		for (int i = 0; i <  str.length();  i++) 
			{
			
			char baelleCh = str.charAt(i);
			char ch = key.charAt(i % key.length());
			
			if(baelleCh == ' ')
			{
				cryptedString2 += baelleCh;	
			}
			
		    char encoding = (char) (((baelleCh - 'a') + (ch - 'a')) % 26 + 'a');
		    cryptedString2 += encoding;
			}

It works now, the only problem is, it adds characters like \ and _. Is there a way to make it not have these when it's encrypting the string? I can't really think of anything that would remove them without messing with the encryption. editting this to add that If I change it to

 

 char encoding = (char) (((baelleCh - 'a') + (Character.getNumericValue(ch)%26 + 'a')) % 26 + 'a');

 

I get a neater string with no odd symbols, however I then run into a problem of, I'm having it not align the words properly. There are spaces, and it's spaced out and looks nice, however there is a 3 letter encrypted string where a 2 letter string should be, same for a 4 and a few 6's. It's quite strange. I'm not sure why.


In Topic: Beale Cipher

10 May 2014 - 09:23 PM

Attempting to convert that over to Java.

 

It keeps getting annoyed saying key needs to be an int.

for (int i = 0; i <  str.length();  i++) 
   {
	char baelleCh = str.charAt(i);
	char ch = key.charAt(i);
			                            
        char encoding = (char)('A' + baelleCh - 'A' + key(i % key.length()) - 'A') % 26);
        cryptedString2 += encoding;
   }

In Topic: JMenu, Listeners, and drawing

10 May 2014 - 07:27 PM

Solved... my images were not in the folder 'images'. >.<.


In Topic: JMenu, Listeners, and drawing

10 May 2014 - 09:23 AM

I would have done it that way, except this was a project that was given to us to have us convert radiobuttons over to JMenuItems.

 

For my Final I've done things that way, where I get one thing working, before trying to get anything else working.


PARTNERS