# JCE example question

Paul Irwin (plirwin@gis.net)
Sun, 21 Mar 1999 20:58:52 -0500

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Sriram M: "Provider for java1.2"
- Previous message: Richard Cardone: "JCE 1.2 Cipher class initialization problem"
- Next in thread: Jan Luehe: "Re: JCE example question"

    Date: Sun, 21 Mar 1999 20:58:52 -0500

    From: Paul Irwin <plirwin@gis.net>

    To: java-security@java.sun.com

    Subject: JCE example question

--------------3A22264DEF85C22A3999C3FD
Content-Type: text/plain; charset="us-ascii"
X-Sun-Content-Length: 237

I've been trying out JCE 1.2 by using the PBE example supplied with the
documentation. However when I use the generateSecret method it keeps
throwing the InvalidKeySpecException. Attached is my code. Any help
would be appreciated.

--------------3A22264DEF85C22A3999C3FD
Content-Type: application/x-unknown-content-type-JBuilder.JavaFile; name="JavaCrypt.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="JavaCrypt.java"
X-Sun-Content-Length: 3163

aW1wb3J0IGphdmEuYXBwbGV0Lio7DQppbXBvcnQgamF2YS5zZWN1cml0eS4qOw0KaW1wb3J0
IGNvbS5zdW4uY3J5cHRvLio7DQppbXBvcnQgY29tLnN1bi5jcnlwdG8ucHJvdmlkZXIuKjsN
CmltcG9ydCBqYXZheC5jcnlwdG8uKjsNCmltcG9ydCBqYXZheC5jcnlwdG8uc3BlYy4qOw0K
aW1wb3J0IGphdmF4LmNyeXB0by5pbnRlcmZhY2VzLio7DQoNCnB1YmxpYyBjbGFzcyBKYXZh
Q3J5cHQgZXh0ZW5kcyBBcHBsZXQNCgkNCnsNCiAgIA0KIAlQQkVLZXlTcGVjIHBiZUtleVNw
ZWM7ICAgIA0KCVBCRVBhcmFtZXRlclNwZWMgcGJlUGFyYW1TcGVjOw0KICBTZWNyZXRLZXlG
YWN0b3J5IGtleUZhYzsNCglTZWNyZXRLZXkgcGJlS2V5Ow0KCUNpcGhlciBwYmVDaXBoZXI7
DQoJDQoJU3RyaW5nIHMgPSAiIjsNCgkg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Q0KCQljYXRjaChqYXZhLnNlY3VyaXR5LkludmFsaWRLZXlFeGNlcHRp
b24gZSkNCgkJew0KCQkNCgkJfQ0KDQoJCQ0KCQkJLy8gT3VyIGNsZWFydGV4dCAgICANCgkJ
Ynl0ZVtdIGNsZWFydGV4dCA9IHN0clBsYWluLmdldEJ5dGVzKCk7DQogICAgLy8gRW5jcnlw
dCB0aGUgY2xlYXJ0ZXh0DQogICAgdHJ5DQoJCXsNCgkJYnl0ZVtdIGNpcGhlcnRleHQgPSBw
YmVDaXBoZXIuZG9GaW5hbChjbGVhcnRleHQpOw0KCQl9DQoJCWNhdGNoKGphdmF4LmNyeXB0
by5CYWRQYWRkaW5nRXhjZXB0aW9uIGUpDQoJCXsNCgkJICANCgkJfQ0KCQljYXRjaChqYXZh
eC5jcnlwdG8uSWxsZWdhbEJsb2NrU2l6ZUV4Y2VwdGlvbiBlKQ0KCQl7DQoJCQ0KCQl9DQoN
CgkJDQoJCQ0KCX0NCg0KDQp9
--------------3A22264DEF85C22A3999C3FD--

- Next message: Sriram M: "Provider for java1.2"
- Previous message: Richard Cardone: "JCE 1.2 Cipher class initialization problem"
- Next in thread: Jan Luehe: "Re: JCE example question"