• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Encryption Code Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Encryption Code Problem


  • Subject: Re: Encryption Code Problem
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Wed, 04 Jun 2003 02:11:16 +0100

Good on you eZL

Thank you very much

Jonathan :^)


From: Enrique Zamudio <email@hidden>
To: Jonathan Fleming <email@hidden>
CC: <email@hidden>
Subject: Re: Encryption Code Problem
Date: Tue, 03 Jun 2003 19:52:45 -0500

"Jonathan Fleming" <email@hidden> wrote:

>
> Ok eZL, this sound good and now that I have seen Jonathan's code I would
> really like to compare his with your suggestion. If you don't mind at all
> can you post a sample. I'm sure Jonathan would be interested too.
>


I think the other suggestion was the same, namely to encode the hash bytes
to hex or base 64. you can use the suggested implementations. I use the
cryptix implementation of base64 encoding, which is stream-based (you can
download it at cryptix.org), they also have a SHA-1 implementation and I
believe they have a hex encoder somewhere as well. So you would do something
like this:


import java.security.*;
import cryptix.util.mime.*;
import java.io.*;

MessageDigest hasher;
try {
    hasher = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
    //whatever
}
hasher.reset();
hasher.update(bytes, 0, bytes.length);

//here you have the raw digest data
byte[] hash = hasher.digest();

//you encode it to base 64
ByteArrayOutputStream bout = new ByteArrayOutputStream();
Base64OutputStream b64out = new Base64OutputStream(bout);
b64out.write(hash);
b64out.close();

//and you get a plain text string with no special characters
String hash_text = new String(bout.toByteArray());

SHA-1 always returns a 20-byte array. If you encode that to base 64 you
should get a 24 or 25 character string.

eZL


_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Encryption Code Problem
  • Next by Date: Re: Internal Data Type for BOOL
  • Previous by thread: Re: Encryption Code Problem
  • Next by thread: Re: Encryption Code Problem
  • Index(es):
    • Date
    • Thread