Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #4311
| X-Received | by 2002:ac8:6ec3:: with SMTP id f3mr15143996qtv.328.1583772914406; Mon, 09 Mar 2020 09:55:14 -0700 (PDT) |
|---|---|
| X-Received | by 2002:a25:6c0a:: with SMTP id h10mr17665057ybc.47.1583772914038; Mon, 09 Mar 2020 09:55:14 -0700 (PDT) |
| Path | csiph.com!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.java.help |
| Date | Mon, 9 Mar 2020 09:55:13 -0700 (PDT) |
| In-Reply-To | <9d1b8fe8af350eb563c30c7d49e57a33@localhost.talkaboutprogramming.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | google-groups.googlegroups.com; posting-host=162.38.222.172; posting-account=cYyrQgoAAACw9RhAzhXa4LliOkBIYXiR |
| NNTP-Posting-Host | 162.38.222.172 |
| References | <9d1b8fe8af350eb563c30c7d49e57a33@localhost.talkaboutprogramming.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <106d16a2-0428-4b74-a042-6b7c4e26bf12@googlegroups.com> (permalink) |
| Subject | Re: java.security.InvalidKeyException: Wrong key size |
| From | samquetinuel@gmail.com |
| Injection-Date | Mon, 09 Mar 2020 16:55:14 +0000 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | quoted-printable |
| Xref | csiph.com comp.lang.java.help:4311 |
Show key headers only | View raw
Le mardi 2 novembre 2004 21:43:43 UTC+1, dmak a écrit :
> Hi,
>
> I am trying to encrypt a string using MD5. Following is the piece of code.
> I get the error "java.security.InvalidKeyException: Wrong key size" at the
> following line
>
> DESedeKeySpec desedeKeySpec = new DESedeKeySpec(pwdhash);
>
> Any help is appreciated . Thank U
>
> Code:-
> public static void main (String args[]) {
> arg = args[0];
>
> try {
> password = "secretpassword1!";
> MessageDigest md = MessageDigest.getInstance("MD5");
> pwdhash = md.digest(password.getBytes());
> md = null;
> DESedeKeySpec desedeKeySpec = new DESedeKeySpec(pwdhash);
> System.out.println("Work");
> SecretKeyFactory keyFactory =
> SecretKeyFactory.getInstance("DESede");
> Key desKey = (Key) keyFactory.generateSecret(desedeKeySpec);
> desCipher = Cipher.getInstance("DESede/ECB/PKCS5Padding");
> desCipher.init(Cipher.ENCRYPT_MODE, desKey);
> }
> catch(Exception e) {
> System.out.println("e "+e);
> }
>
> String encr = encrypt(arg);
> }
wtf
Back to comp.lang.java.help | Previous | Next | Find similar
Re: java.security.InvalidKeyException: Wrong key size samquetinuel@gmail.com - 2020-03-09 09:55 -0700
csiph-web