crypto and decrypt Archives

SYMMETRIC KEY CRYPTO?

Suppose that the ciphertext in equation 3.7 had been encrypted in CBC mode instead
of ECB mode. If Trudy believes ECB mode is used and tries the same cut-and-paste
attack, which blocks decrypt correctly?
equation 3.7 C0,C1,C5,C3,C4,C2

equation 3.6 Pi = D(Ci,K) ⊕ Ci−1 for i = 0, 1, 2, . . . .

[JAVA] Need help with encryption?

I’m writing an email address and pass to be stored in a .db file, but it can easily be stolen by just reading it. How can I encrypt it without being easily decrypted by an outside source? I also need to be able to decrypt it for the program.

Can I use Java’s Security/Crypto API or do I have to create my own encryption method? And how can I make sure that someone can’t just decompile my .class file and read the algorithm?

Thanks a bunch, giving out best answer,
~Arthur
SOLVED, PLEASE ANSWER MY NEW ENCRYPTION QUESTION: http://answers.yahoo.com/question/index?qid=20110221154027AAbXZoP

encryption decryption java coding?

You have just been hired by the CIA as a programmer in the encryption department. Your job is
to write a class called Crypto. One method, encrypt, will accept a String that represents the sentence to be encrypted. It will return a String that is the sentence with all v’s (big or small)
replaced with “ag’,r”, all m’s (big or small) with “ssad”, all g’s (big or small) with “jeb..w”, and
all b’s (big or small) with “dug>?/”.
The class contains another method, decrypt, that accepts a String that represents the sentence to
be decrypted. In this method the reverse process described above is performed. It returns a String
that is the original sentence before encryption.
Use the following Tester class to insure that your methods work.
import java.io.*;
import java.util.*;
public class Tester
{
public static void main(String args[])
{
Scanner kbReader = new Scanner(System.in);
System.out.print(“Enter a sentence that is to be encrypted: ”);
String sntnc = kbReader.nextLine( );
System.out.println(“Original sentence = ” + sntnc);
Crypto myCryptObj = new Crypto( );
String encryptdSntnc = myCryptObj.encrypt(sntnc);
System.out.println(“Encrypted sentence = ” + encryptdSntnc);
String decryptdSntnc = myCryptObj.decrypt(encryptdSntnc);
System.out.println(“Decrypted sentence = ” + decryptdSntnc);
}
}
Test with this sentence: “This is a very big morning.” After running your program, your screen
should appear as follows:
Enter a sentence that is to be encrypted: This is a very big morning.
Original sentence = This is a very big morning.
Encrypted sentence = This is a ag’,rery dug>?/ijeb..w ssadorninjeb..w.
Decrypted sentence = This is a very big morning.

Project… Encryption/Decryption?

You have just been hired by the CIA as a programmer in the encryption department. Your job is
to write a class called Crypto. One method, encrypt, will accept a String that represents the
sentence to be encrypted. It will return a String that is the sentence with all v’s (big or small)
replaced with “ag’,r”, all m’s (big or small) with “ssad”, all g’s (big or small) with “jeb..w”, and
all b’s (big or small) with “dug>?/”.
The class contains another method, decrypt, that accepts a String that represents the sentence to
be decrypted. In this method the reverse process described above is performed. It returns a String
that is the original sentence before encryption.
Use the following Tester class to insure that your methods work.
import java.io.*;
import java.util.*;
public class Tester
{
public static void main(String args[])
{
Scanner kbReader = new Scanner(System.in);
System.out.print(“Enter a sentence that is to be encrypted: ”);
String sntnc = kbReader.nextLine( );
System.out.println(“Original sentence = ” + sntnc);
Crypto myCryptObj = new Crypto( );
String encryptdSntnc = myCryptObj.encrypt(sntnc);
System.out.println(“Encrypted sentence = ” + encryptdSntnc);
String decryptdSntnc = myCryptObj.decrypt(encryptdSntnc);
System.out.println(“Decrypted sentence = ” + decryptdSntnc);
}
}
Test with this sentence: “This is a very big morning.” After running your program, your screen
should appear as follows:
Enter a sentence that is to be encrypted: This is a very big morning.
Original sentence = This is a very big morning.
Encrypted sentence = This is a ag’,rery dug>?/ijeb..w ssadorninjeb..w.
Decrypted sentence = This is a very big morning.

I am trying to learn more about the RSA Algorithm. I have researched several pages on Google and have a fairly clear idea of what the algorithm entails — I don’t exactly understand *why* it works, but I believe I understand a good amount as to how one would encrypt/decrypt a message. My question, is how is this algorithm applied in real life? I mean, how does one generate two large primes? SInce there is no known algorithm for factoring the product of two primes it seems that there would also be no known algorithm for generating numbers that are prime? Also, is the arithmetic carried out? Raising a message to a power of significant size isn’t going to work well with a 32 or even 64bit processor. I assume some type of addon library is used to accomodate the larger numbers? How are these implemented? Finally, I understand that these mechanisms already exist and re-inventing the wheel is often dangerous in terms of crypto, but I just want to do it as a learning exercise.
My understanding of RSA algo:

1) Choose 2 large distinct primes p and q
2) Calculate modulus as N = p*q
3) Calculate totient as (p-1)(q-1)
4) Choose e such that 1 < e < (p-1)(q-1) and e is coprime with (p-1)(q-1). [Does this mean e could ever be 2? It seems an odd number would be required for e?]
5) Find d such that ed = 1 mod (p-1)(q-1)
[Is there only 1 d that works or does it matter which solution I choose?? What is an efficient way to calculate this??]

6) c = m^e mod N where m = msg expressed as number … whats an efficient way to raise m to such a large exponent? I realize modular arithmetic bounds this somewhat, but still the calculation could/should be much larger than 32 or 64bit values…
McDonger: Thanks for your response. I guess I’m looking for more detailed information as to how it gets split up and calculated. The symmetric encryption (the key passed via the PKE) isn’t so much of an interest to me.

Thanks.

Hello,

I am trying to learn more about the RSA Algorithm. I have researched several pages on Google and have a fairly clear idea of what the algorithm entails — I don’t exactly understand *why* it works, but I believe I understand a good amount as to how one would encrypt/decrypt a message. My question, is how is this algorithm applied in real life? I mean, how does one generate two large primes? SInce there is no known algorithm for factoring the product of two primes it seems that there would also be no known algorithm for generating numbers that are prime? Also, is the arithmetic carried out? Raising a message to a power of significant size isn’t going to work well with a 32 or even 64bit processor. I assume some type of addon library is used to accomodate the larger numbers? How are these implemented? Finally, I understand that these mechanisms already exist and re-inventing the wheel is often dangerous in terms of crypto, but I just want to do it as a learning exercise.
My understanding of RSA algo:

1) Choose 2 large distinct primes p and q
2) Calculate modulus as N = p*q
3) Calculate totient as (p-1)(q-1)
4) Choose e such that 1 < e < (p-1)(q-1) and e is coprime with (p-1)(q-1). [Does this mean e could ever be 2? It seems an odd number would be required for e?]
5) Find d such that ed = 1 mod (p-1)(q-1)
[Is there only 1 d that works or does it matter which solution I choose?? What is an efficient way to calculate this??]

6) c = m^e mod N where m = msg expressed as number … whats an efficient way to raise m to such a large exponent? I realize modular arithmetic bounds this somewhat, but still the calculation could/should be much larger than 32 or 64bit values…

encryption challenge !solve this :?

The following strings are ciphertexts that have been encrypted using one of the classical crypto-systems that were discussed in class. Each of them decrypt to an English sentence without any whitespace or punctuation. Cryptanalyze each one and provide the decrypted plaintext as well as the secret key used to produce it. Explain the process you went through and include any script you used in the cryptanalysis process in your submission.

1) Affine Cipher – In the class, we studied the shift cipher. A similar cipher is called the affine cipher, which works as follows.
Encryption: Each plaintext letter p is encrypted to obtain a ciphertext
letter c such that c = ap + b (mod 26), where a and b are numbers between 0,1,….,25, and represent the secret key.
Decryption: Each ciphertext letter c is decrypted to obtain a
plaintext letter such that p = (c-b)a-1 (mod 26).

WETNOOZATDZQETGZBNBQTDZNKDNBTVOWETFVGTJTATGNKFVAVNKQENITWZDBRIBWZWRWZVADZQETGWETDZQETGBQGZFNGXHTNPATBBDVFTBOGVFWETONDWWENWZOWETDGXQWNANKXBWDNAYZBDVMTGIXFTNABVOOGTLRTADXNANKXBZBIGRWTOVGDTJRTBBZAJVGVWETGHZBTWETQKNZAWTCWVOWHVDZQETGWTCWDENGNDWTGBWETAWETPTXDNAITVIWNZATYIXBVKMZAJNBZFRKWNATVRBTLRNWZVABZADTHTPAVHNNAYFNGTGTKNWZMTKXQGZFTWEZBDNAITRBTYWVGNQZYKXYZBDNGYFNAXONKBTPTXBZANANRWVFNWTYBXBWTF

2)Vigenere Cipher:

GFYOCMGNUFQQBPXVQUYMHTLIAQYAQCPYFFRLVLABDFRRNRPMNLXASGOCLFYHQNOAANHYNVMHZYLXQUPMGOGHNRCBLHRTYENOGRITCNUCLOCZBPYFMGRYXZGLNZFRNYBNFRYWGSUYJSQMGRKIEGTRPUABIZQNEGHTQISABNPUPRYEQZBPNUCCENUFQQBPXFYHQPYCJUPCNUCGJGNUMNUCLEYHQMGFRLVLAFCPRPSPMOCJYBDGBLNUQNUCHGFYECMGFYECMGMZHQMRJYPRCAENUCMUMLGRBRDUZGFVYLNLXGFYRYMVCMGRIECGRKVRPUABBBJXVLABLNBGNSMLRTYE

I have a message that I want to distribute to multiple people, but I only want to make one copy of the same encrypted message. In that case, I want to encrypt the content with a single public key, but each of the recipients has to use his/her unique private key to decrypt.

Is such a single-public-key/multiple-private-keys relationship possible?