JCDK with cryptographic extension
Is there anyone that can me where to download the binary version for Java Card Development Kit 2.2 with cryptographic extension? It is mentioned in the release notes from Java Card Development Kit 2.2. Many thanks.
you will need to license it from $un.
Similar Messages
-
Does anyone know of any Sun Classes for Java Cryptographic Extension -JCE ?
Hello - anyone know of any Sun Classes for Java Cryptographic Extension? If so do you have the Sun class code/s?
Edited by: Mister_Schoenfelder on Apr 17, 2009 11:31 AMMaybe this can be helpful?
com.someone.DESEncrypter
======================
package com.someone;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
public class DESEncrypter {
Cipher ecipher;
Cipher dcipher;
// 8-byte Salt
byte[] salt = {
(byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
(byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
// Iteration count
int iterationCount = 19;
public DESEncrypter(String passPhrase) {
try {
// Create the key
KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
SecretKey key = SecretKeyFactory.getInstance(
"PBEWithMD5AndDES").generateSecret(keySpec);
ecipher = Cipher.getInstance(key.getAlgorithm());
dcipher = Cipher.getInstance(key.getAlgorithm());
// Prepare the parameter to the ciphers
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
// Create the ciphers
ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
} catch (java.security.InvalidAlgorithmParameterException e) {
e.printStackTrace();
} catch (java.security.spec.InvalidKeySpecException e) {
e.printStackTrace();
} catch (javax.crypto.NoSuchPaddingException e) {
e.printStackTrace();
} catch (java.security.NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (java.security.InvalidKeyException e) {
e.printStackTrace();
public DESEncrypter(SecretKey key) {
try {
ecipher = Cipher.getInstance("DES");
dcipher = Cipher.getInstance("DES");
ecipher.init(Cipher.ENCRYPT_MODE, key);
dcipher.init(Cipher.DECRYPT_MODE, key);
} catch (javax.crypto.NoSuchPaddingException e) {
e.printStackTrace();
} catch (java.security.NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (java.security.InvalidKeyException e) {
e.printStackTrace();
public String encrypt(byte[] data) {
return encrypt(new sun.misc.BASE64Encoder().encode(data), false);
public byte[] decryptData(String s) throws IOException {
String str = decrypt(s, false);
return new sun.misc.BASE64Decoder().decodeBuffer(str);
public String encrypt(String str, boolean useUTF8) {
try {
// Encode the string into bytes using utf-8
byte[] utf8 = useUTF8 ? str.getBytes("UTF8") : str.getBytes();
// Encrypt
byte[] enc = ecipher.doFinal(utf8);
// Encode bytes to base64 to get a string
return new sun.misc.BASE64Encoder().encode(enc);
} catch (javax.crypto.BadPaddingException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (java.io.IOException e) {
e.printStackTrace();
return null;
public String decrypt(String str, boolean useUTF8) {
try {
// Decode base64 to get bytes
byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);
// Decrypt
byte[] utf8 = dcipher.doFinal(dec);
// Decode using utf-8
return useUTF8 ? new String(utf8, "UTF8") : new String(utf8);
} catch (javax.crypto.BadPaddingException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (java.io.IOException e) {
e.printStackTrace();
return null;
// Here is an example that uses the class
public static void main(String[] args) {
try {
// Generate a temporary key. In practice, you would save this key.
// See also e464 Encrypting with DES Using a Pass Phrase.
SecretKey key = KeyGenerator.getInstance("DES").generateKey();
// Create encrypter/decrypter class
DESEncrypter encrypter = new DESEncrypter(key);
// Encrypt
String encrypted = encrypter.encrypt("Don't tell anybody!", true);
// Decrypt
String decrypted = encrypter.decrypt(encrypted, true);
} catch (Exception e) {
e.printStackTrace();
try {
// Create encrypter/decrypter class
DESEncrypter encrypter = new DESEncrypter("My Pass Phrase!");
// Encrypt
String encrypted = encrypter.encrypt("Don't tell anybody!", true);
// Decrypt
String decrypted = encrypter.decrypt(encrypted, true);
} catch (Exception e) {
e.printStackTrace();
} -
Extensive (very very very extensive) memory usage of host application with CS extension
Hi!
I tried this only under Photoshop CS5 and InDesign CS5 under Windows 7.
When you open and close CS extension panel, the memory taken by Photoshop (InDesign) increases by 6-30MB!
In case of the simple HelloPhotoshop (HelloInDesign) panel from the examples, compiled in release mode, when you open it and close, - it's about 6-10MB each time you do it. And in case of a more complex panel, which uses AIR, etc. it's about 30MB per one panel close/open.
When I use some panels in 5-10 minutes Photoshop (InDesign) increases its memory pool from 600MB up to 1,2 GB. And more. And this memory is never freed, only until Photoshop (InDesign) shutdown.
I tried freeing all my arrays, killing display objects, etc. - nothing helped. Even a simple HelloPhotoshop (HelloInDesign) that does nothing eats memory.
By the way, InDesign eats memory a lot faster .James, thank you for the very fast answer! I did various tests on the weekend on my computer and computer of my friend.
And I can say, that Debug flag doesn't affect memory consumption. They still eat memory. My steps to reproduce are as follows:
(Windows 7 32 bit)
Photoshop CS5:
1) set HKEY_CURRENT_USER\Software\Adobe\CSXS2Preferences\PlayerDebugMode to 0
2*) check HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\CSXS2Preferences (just in case)
3) Compile HelloPhotoshop example to ZXP and install via Extension manager
4) restart computer
5) Run Photoshop CS5 - Memory consumption: 100 096 KB
6) Open HelloPhotoshop and close it 10 times
7) Memory consumption: 155 840 - 5,574 MB per one close/open
Maybe a garbage collector is expected to run and free this memory, but it never happened in my case. The memory pool was increasing to 1 GB when I was working with one of my panels - with no documents open in Photoshop
In InDesign I tried the same thing with HelloInDesign ( I had to close the panel completely and then open with Window | Extensions | HelloInDesign)
Memory consumption on start: 118 516
Memory consumption after 10 open/close cycles: 197 516
It's 7,9 MB per one close/open
It's the simpliest panel test. When I'm using AIR libraries the memory usage is increasing a lot faster. -
I have many photos with file extension of .PDD and that Photo Deluxe 4 no longer will operate in Win 7. How can I open? Next in Elements 11, how do I load and print different pictures and different sizes options on the same page?
Thanks,
Shirsbmgrams wrote:
I have many photos with file extension of .PDD and that Photo Deluxe 4 no longer will operate in Win 7. How can I open?
See here:
Reading PhotoDeluxe PDD Files -
Firefox can't read any Bookmark on my Mac that was imported from my PC with file extension .url. Safari reads them all fine. Is there a fix, so I can use Firefox instead of Safari? Many thanks if so. I have the latest version of Firefox
== URL of affected sites ==
http://anysite.url
== User Agent ==
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7Hello JF.
I don't think that extension is supported. I believe Firefox can only read .json and .html.
You may want to read this though:
[http://support.mozilla.com/en-US/kb/Importing+bookmarks+and other data from Safari Importing bookmarks and other data from Safari] -
Quicktime no longer exporting my movies with file extensions
Hi all, QT is no longer exporting or saving movies with file extensions. The only way i can view extensions is to turn on all extensions in finder which means i get .app in my apps folder which i find looks naff, have i changed something to cause this?
CheersIn the export or save dialog windows is a check box to "hide" the file extension.
Remove that check mark. -
Receiving multiple files with dual extension using file adapter
Hi,
The scenario where I am implementing requires multiple files of different names to be picked(ABC.txt) and dropped at destination(ABC.txt.pgp) up by my File Sender and Receiver adapters. Any idea on about how the configuration for receiving multiple files with dual extension for receiver adapter is to be done?
Note:- currently, The scenario is working fine without dual extension. i.e Its picking all files which starts with ABC and creating at destination as it is. even I configured as ABC.txt.pgp, but its not creating the second extension.
Thanks in Advance
ManmadhaHi,
Try to concatenate '.pgp ' to the source file name to create the target file name for the receiver file adapter, by accessing the Adapter Specific Attributes using Java user defined function. This might work.
Reference links:
<a href="http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm">SAP Help - Accessing Adapter Specific Attributes</a>
<a href="/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14 - XI: The same filename from a sender to a receiver file adapter - SP14</a>
Regards,
S.Santhosh Kumar -
How do I add a filter in JFileChooser for files with no extension?
Is it possible to have a filter with that filters out files with no extension in a JFileChooser?
Any help is appreciated.
ShankarWhen you override accept(File), get the filename from the File object, and parse out the extension. I don't remember there being an easy way to get the extension besides looking for a dot and parsing. If there's no extension, accept it.
-
Problem with upgrade Extension Manager 6.0.4
Problem with upgrade Extension Manager 6.0.4, code error U44M1P7
What version of the Adobe Application Manager are you using? Which operating system are you using?
-
Itunes document manager pro will not open a document with .cwk extension. It will catch the document then error message states that it cannot open document. Can anyone tell me what Im doing wrong?
Forgive my ignorance but I have never hear of iTunes Document Manager Pro. If you mean Document Manager Pro, i was able to find that. Back to your problem, have you tried opening one of those files in the iOS iWorks apps? Form the quick read that I did about this, .cwk files can be opened by Pages, Numbers or Keynote, depending on what type of document that it is and those files can be read by Document Manager Pro, after properly saving them. I don't see that you can go directly from the .cwk file in Document Manager Pro without converting them first.
I took a very quick look at the app, so I may be a missing something about its capability. -
Receiving word docs with .docx extension
I have been receiving word documents with .docx extension, which then open only in Text Edit rather than Word for Mac. It loses the formatting and the ability to edit and return to the sender. Is it because of the version of Word they are using? Can I convert it into a document I can open in Word?
Can I convert it into a document I can open in Word?
At the bottom:
http://www.microsoft.com/mac/downloads.mspx?pid=Mactopia_AddTools&fid=EDB6CD8F-8 32C-4123-8982-AC0C601EA0A7#viewer -
I am trying to find out how to assign files with particular extensions to the appropriate software. At the moment when I create a file using Word it is apparently given the extension .docx but Word doesn't recognise its own files. How do I allocate the extension .docx to Word? There used to be a way of doing it, I think under "Preferences" but I can't seem to find it.
Still in the same location:
File > Get Info > Open with (select) > Change All (button) -
How to Handle Files With No Extension
Many open source softwares come with some text files named "README" or "TODO" with no extension.
All my txt files are opened with MacVim, but these files without extensions are open with TextEdit.app by default .
The question is HOW do I change it so that thay're NOT open with TextEdit.app but open with MacVim.app when being double-clicked .
Thank you, And sorry for my pool English.Click on the file and do a Get-Info. command-I. In the Open with drop down menu click on the drop down and if your MacVim appears select it. If it doesn't select other and navigate to where MacVim is located. Select it and then select open all.
-
Error in opening draft email saved with msg extension
I am attempting to create a email and save it on local hard disc. The email is a file having msg extension. So that it can be opened with MS Outlook. Also I want it to be in DRAFT mode. Like we can create draft email with MS Outlook. This message will have multiple attachmets.
Thus when user opens this file, it will get opened with MS Outlook and user will be able to edit the message text, TO/CC list, attachments.
I am using MimeMessage.writeTo(Outstream) API to save the message to a file, say C:\test.msg
But if I double click test.msg in explorer to open it, it gives error:
Can't open file C:\test.msg. The file may not exist, you may not have permissions to open it, or it may be open in another program.
Is it possible to create draft Outlook email message with msg extension?
If yes, how?
My code:
Properties props = new Properties();
props.load(new FileInputStream("C:/email.settings.properties"));
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props);
session.setDebug(debug);
// create a message
msg = new MimeMessage(session);
//Create message from saved email
File savedFile = new File("C:/test.msg");
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = null;
addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients);
msg.setRecipients(Message.RecipientType.TO, addressTo);
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
DataSource ds = new FileDataSource("C:/WhichSQLServer.pdf");
attachmentBodyPart.setDataHandler(new DataHandler(ds));
attachmentBodyPart.setFileName("WhichSQLServer.pdf");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(attachmentBodyPart);
msg.setContent(multipart);
//msg.setFlag(Flags.Flag.DRAFT, true);
msg.getFlags().add(Flags.Flag.DRAFT);
msg.setFileName("test.msg");
msg.saveChanges();
FileOutputStream os = new FileOutputStream("C:/test.msg");
msg.writeTo(os);
os.flush();
os.close();Outlook Msg files aren't as easy to write as you would believe. They are a propretary format that microsoft uses based on the DocFile format that Word and Excel uses.
If you did the MimeMessage.writeTo(out) and saved it to a .eml file Outlook Express will open it, but Outlook doesn't directly read this file type.
I've started on a library to allow the creation of Outlook msg files, right now it only allows you to set text, dates, long, and boolean values on the email message (which means you can set stuff like the recieved date/time, subject, body, to, from, etc), but it does not yet support attachments or extra recipents (CC, BCC, etc). I'll be updating the copy on my site as soon as I get the other stuff working (which isn't as easy as it sounds).
Priasoft has a library available that can do what you want however.
travis (at) overwrittenstack.com -
Exporting from a 2D line graph with .jpeg extension
Is there any way to export from an ordinary 2D line graph with .jpeg extension so that with using this image i will improve my result of exporting excel.
e.g. i have found and example and added a button as you will see when you run this code.I will click this button and it will export this line graph with extension .jpeg so that i will see it as an ordinary image at my home directory.
Thanks for any helpful comment
Regars,
Serhat
* To change this template, choose Tools | Templates
* and open the template in the editor.
* @author led1433
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;
public class LineGraph
public static void main(String[] args)
int x1 = 1000,y1 = 0;
JFrame f = new JFrame();
JButton exportToJPegButton = new JButton("EXPORT WITH JPEG");
exportToJPegButton.setToolTipText("Exports Graph with extension *jpeg");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
exportToJPegButton.setSize(200,25);
f.add(exportToJPegButton).setLocation(x1, y1);
f.getContentPane().add(new GraphPanel());
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
class GraphPanel extends JPanel
final int
HPAD = 60,
VPAD = 40;
int[] data;
Font font;
public GraphPanel()
data = new int[] {
120, 190, 211, 75, 30, 290, 182, 65, 85, 120, 100, 101
font = new Font("lucida sans regular", Font.PLAIN, 16);
setBackground(Color.white);
protected void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setFont(font);
FontRenderContext frc = g2.getFontRenderContext();
int w = getWidth();
int h = getHeight();
// scales
float xInc = (w - HPAD - VPAD) / 11f;
float yInc = (h - 2*VPAD) / 10f;
int[] dataVals = getDataVals();
float yScale = dataVals[2] / 10f;
// ordinate
g2.draw(new Line2D.Double(HPAD, VPAD, HPAD, h - VPAD));
// tic marks
float x1 = HPAD, y1 = VPAD, x2 = HPAD - 3, y2;
for(int j = 0; j < 10; j++)
g2.draw(new Line2D.Double(x1, y1, x2, y1));
y1 += yInc;
// labels
String text; LineMetrics lm;
float xs, ys, textWidth, height;
for(int j = 0; j <= 10; j++)
text = String.valueOf(dataVals[1] - (int)(j * yScale));
textWidth = (float)font.getStringBounds(text, frc).getWidth();
lm = font.getLineMetrics(text, frc);
height = lm.getAscent();
xs = HPAD - textWidth - 7;
ys = VPAD + (j * yInc) + height/2;
g2.drawString(text, xs, ys);
// abcissa
g2.draw(new Line2D.Double(HPAD, h - VPAD, w - VPAD, h - VPAD));
// tic marks
x1 = HPAD; y1 = h - VPAD; y2 = y1 + 3;
for(int j = 0; j < 12; j++)
g2.draw(new Line2D.Double(x1, y1, x1, y2));
x1 += xInc;
// labels
ys = h - VPAD;
for(int j = 0; j < 12; j++)
text = String.valueOf(j + 1);
textWidth = (float)font.getStringBounds(text, frc).getWidth();
lm = font.getLineMetrics(text, frc);
height = lm.getHeight();
xs = HPAD + j * xInc - textWidth/2;
g2.drawString(text, xs, ys + height);
// plot data
x1 = HPAD;
yScale = (float)(h - 2*VPAD) / dataVals[2];
for(int j = 0; j < data.length; j++)
y1 = VPAD + (h - 2*VPAD) - (data[j] - dataVals[0]) * yScale;
if(j > 0)
g2.draw(new Line2D.Double(x1, y1, x2, y2));
x2 = x1;
y2 = y1;
x1 += xInc;
private int[] getDataVals()
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
for(int j = 0; j < data.length; j++)
if(data[j] < min)
min = data[j];
if(data[j] > max)
max = data[j];
int span = max - min;
return new int[] { min, max, span };
}GraphPanel stays the same.
public class JpegExport {
public static void main(String[] args) {
final GraphPanel graphPanel = new GraphPanel();
JButton exportToJPegButton = new JButton("EXPORT WITH JPEG");
exportToJPegButton.setToolTipText("Exports Graph with extension *jpeg");
exportToJPegButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
exportToJpeg(graphPanel);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(exportToJPegButton, BorderLayout.NORTH);
f.getContentPane().add(graphPanel, BorderLayout.CENTER);
f.setSize(400, 400);
f.setLocationRelativeTo(null);
f.setVisible(true);
private static void exportToJpeg(GraphPanel graphPanel) {
try {
int w = graphPanel.getWidth();
int h = graphPanel.getHeight();
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
graphPanel.paint(g2);
g2.dispose();
ImageIO.write(image, "jpeg", new File("export.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
Maybe you are looking for
-
How do I remove photo stream pop-up request to download my files?
My preferences say no pop-ups, why the constant photo stream request to download my photo files?
-
I requested my MAC from my current ISP as BT told me upon ordering my new package. This was last week.... I phoned 1st and was told I had to e-mail, which I did, got confirmation e-mail, then the next day they try to get me to stay with them, when I
-
External HD nowhere to be seen.
Hello, I hope someone really could help me out in here. Finder froze while my external HD was plugged in, I shut down finder and then opened it again hoping that it would run smoothly, noticing that it did not help... I then turned my Mac off (while
-
Installing 10g on Win2K3 Server
I have been trying to Install 10g on Win2K3 server logged in as Administrator. I seem to get through the installation OK until the Database Creation stage where it fails with the following: At Java.lang.thread.run(Thread.java.534) it fails with DIM-0
-
Hi Everyone, Would anyone Please give me steps for RFC to File Scenario. Thanks & Regards, Varun