Welcome to Dream.In.Code
Become a Java Expert!

Join 150,422 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,099 people online right now. Registration is fast and FREE... Join Now!




vigenere

 
Reply to this topicStart new topic

vigenere, decrypt a text and find the key

becirovic
4 Apr, 2008 - 02:47 AM
Post #1

New D.I.C Head
*

Joined: 4 Apr, 2008
Posts: 3

i want to decrypt a text and also find the key using the vigenere.the key must have 4 chars
User is offlineProfile CardPM
+Quote Post

1lacca
RE: Vigenere
4 Apr, 2008 - 03:00 AM
Post #2

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: code.gif

Thanks.
User is offlineProfile CardPM
+Quote Post

becirovic
RE: Vigenere
4 Apr, 2008 - 03:17 AM
Post #3

New D.I.C Head
*

Joined: 4 Apr, 2008
Posts: 3

CODE
private static String EncryptVigenere ( int key , String plaintext ) {
        
    if (plaintext == null) return null;
    
    String ciphertext = "";
    for (int c = 0; c < plaintext.length(); c++ ) {
        
        ciphertext += shiftChar(key , plaintext.charAt(c));
    }
    return ciphertext;



i cant find the other way.just to find the key..

i want to be returnt the key

This post has been edited by becirovic: 4 Apr, 2008 - 03:14 AM
User is offlineProfile CardPM
+Quote Post

1lacca
RE: Vigenere
4 Apr, 2008 - 03:36 AM
Post #4

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
I can't understand your problem. Are you looking for the decrypting function?
User is offlineProfile CardPM
+Quote Post

becirovic
RE: Vigenere
4 Apr, 2008 - 03:55 AM
Post #5

New D.I.C Head
*

Joined: 4 Apr, 2008
Posts: 3

QUOTE(1lacca @ 4 Apr, 2008 - 04:36 AM) *

I can't understand your problem. Are you looking for the decrypting function?



QUOTE(becirovic @ 4 Apr, 2008 - 04:51 AM) *

QUOTE(1lacca @ 4 Apr, 2008 - 04:36 AM) *

I can't understand your problem. Are you looking for the decrypting function?


i have the plaintext and the ciphertext and i wnat to find the key.Can you please help me?


i have the plaintext and the ciphertext and i want to find the key.Can you please help me?
User is offlineProfile CardPM
+Quote Post

pbl
RE: Vigenere
4 Apr, 2008 - 07:43 AM
Post #6

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,592



Thanked: 233 times
Dream Kudos: 75
My Contributions

You mean something like:

CODE
private static int getKey (String ciphertext  , String plaintext ) {
        
    for(int i = 0; i < 16; i++) {
                   String cipherTest = EncriptVigenere(i, plaintext);
                   if(cipherTest.equals(ciphertext))
                      return i;
    }
                // could not find the key
                return -1;
                


?

User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 08:30PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month