This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Please send me one example of Encryption/Decryption

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please send me JCE encryption/decryption example
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai
what JCE means??
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ther ...
the below code wil work when u download com.dstc.* package

import java.io.*;
import com.dstc.security.provider.DSTC;
import javax.crypto.*;
import javax.crypto.Cipher.*;
import java.security.*;
import java.security.spec.*;
import java.security.interfaces.*;
import java.security.Provider.*;

public class EncTest {


public static void main(String args[]){


//String text = "Hello";

try {

Security.addProvider(new DSTC());
String text = "RAO";

//Provider pp = new
System.out.println();
System.out.println();
System.out.println("Generating a DESede (TripleDES) key...");
// Create a TripleDES key
System.out.println();
System.out.println();
//KeyGenerator keyGenerator = KeyGenerator.getInstance(KeyStore.getDefaultType());

KeyGenerator keyGenerator = KeyGenerator.getInstance("DES");
//KeyGenerator keyGenerator = KeyGenerator.getInstance("PBEwithMD5andDE5-CBC");

keyGenerator.init(56); // need to initialize with the keysize

Key key = keyGenerator.generateKey();

String keyy = key.toString();

System.out.println();
System.out.println();
System.out.println("Done generating the key and the key is ... "+keyy);

//System.out.println("The Security Manager is"+System.getSecurityManager());


//Create a cipher using that key to initialize it

// Cipher cipher = Cipher.getInstance("PBEwithMD5andDE5-CBC");


Cipher cipher = Cipher.getInstance("DES");


System.out.println();
System.out.println();
System.out.println("The Given Text is "+text);


cipher.init(Cipher.ENCRYPT_MODE, key);

byte[] plaintext = text.getBytes("UTF8");

// Print System.out the bytes of the plaintext
//System.out.println("\nPlaintext: "+plaintext);


for (int i=0;i<plaintext.length;i++) {



System.out.print(plaintext[i]+" ");



}
// Perform the actual encryption

byte[] ciphertext = cipher.doFinal(plaintext);
// Print System.out the ciphertext

System.out.print("\n\nCiphertext: ");
String s=null;
for (int i=0;i<ciphertext.length;i++) {


System.out.print(ciphertext[i]+" ");


}

System.out.println();
System.out.println();
s = ciphertext.toString();
System.out.println("The CypherText is "+s);
// Re-initialize the cipher to decrypt mode
cipher.init(Cipher.DECRYPT_MODE, key);

// Perform the decryption
byte[] decryptedText = cipher.doFinal(ciphertext);
String output = new String(decryptedText,"UTF8");

System.out.println();
System.out.println();
System.out.println("\n\nDecrypted text: "+output);
}catch(Exception e){


System.out.println(e.getMessage());

}

}


}
JCE stands for Java Cryptography Extension
Rao...
mail me back
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Raghavender
can u pl. tell from which site we have to download the package com.dstc.* package
srinath


[This message has been edited by srinath rammohan (edited September 11, 2001).]
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guess what! You have your answer in your question !!!
try www.dstc.com
When you choose a prefix for a package, it's recommended by sun
to use the address site in the reverse order (without www).
------------------
Laurent Leonard
Laurent.Leonard@advalvas.be
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic