PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Creating password hash value
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Creating password hash value

Réponse
 
LinkBack Outils de la discussion
Vieux 16/05/2007, 12h36   #1
Prince Al
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Creating password hash value

Hi,

Before I start, I want to apologise for mixing a unix and Java. I
wasn't really sure which group to post in, but figured that seeing as
my query ultimately involves unix tools, it should go in here.
However, if someone knows of a better group for this, please let me
know!

I am trying to write a script (KSH) that takes in a list of passwords
and returns a list hash equivalents. From what I have gleaned on the
interweb, I should be using openssl and associated utilities, which I
have been doing and creating hashes quite nicely.

The problem is that I cannot get the hash result of TDS123 to equal
that of the hash result from the following Java code:

public static String hashPassword(String password) {
MessageDigest md = null;

try { md = MessageDigest.getInstance("MD5"); }
catch (NoSuchAlgorithmException e) { // Ignore this error as
we have hard-coded the algorithm }

md.update(password.getBytes());
byte[] digestedPwdBytes = md.digest();
String digestedPwdString = new
String(Util.encodeBase64(digestedPwdBytes));
// Base64.encode
return digestedPwdString.trim();
}

The Hash returned by the above Java code is: zZyZDPFGJ4emgl4gi1+Mmg==
and no matter how many different combinations I try, I cannot get the
*nix output to be the same.

Any ideas or advice would be very much appreciated!

Cheers

Tim

  Réponse avec citation
Vieux 16/05/2007, 14h15   #2
Janis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Creating password hash value

On 16 Mai, 13:36, Prince Al <timothy.h...@gmail.com> wrote:
> Hi,
>
> Before I start, I want to apologise for mixing a unix and Java. I
> wasn't really sure which group to post in, but figured that seeing as
> my query ultimately involves unix tools, it should go in here.
> However, if someone knows of a better group for this, please let me
> know!


The group is okay for the shell part; unfortunately you haven't
included any shell code at all.

> I am trying to write a script (KSH) that takes in a list of passwords
> and returns a list hash equivalents. From what I have gleaned on the
> interweb, I should be using openssl and associated utilities, which I
> have been doing and creating hashes quite nicely.
>
> The problem is that I cannot get the hash result of TDS123 to equal
> that of the hash result from the following Java code:
>
> public static String hashPassword(String password) {
> MessageDigest md = null;
>
> try { md = MessageDigest.getInstance("MD5"); }
> catch (NoSuchAlgorithmException e) { // Ignore this error as
> we have hard-coded the algorithm }
>
> md.update(password.getBytes());
> byte[] digestedPwdBytes = md.digest();
> String digestedPwdString = new
> String(Util.encodeBase64(digestedPwdBytes));
> // Base64.encode
> return digestedPwdString.trim();
> }
>
> The Hash returned by the above Java code is: zZyZDPFGJ4emgl4gi1+Mmg==
> and no matter how many different combinations I try, I cannot get the
> *nix output to be the same.
>
> Any ideas or advice would be very much appreciated!


Above output is the base64 encoded MD5 hash of "TDS123", right?

All I can suggest is to inspect each input and output for all
processing steps (MD5 and base64), once for your Java code and
once for the tools you use in your shell code.

If you can't find the problem then, provide more information; all
input/output data (incl. intermediate results), the concrete tools
used, the calling syntax you used.

Janis

>
> Cheers
>
> Tim



  Réponse avec citation
Vieux 17/05/2007, 02h44   #3
Erik Max Francis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Creating password hash value

Prince Al wrote:

> The Hash returned by the above Java code is: zZyZDPFGJ4emgl4gi1+Mmg==
> and no matter how many different combinations I try, I cannot get the
> *nix output to be the same.


Well, what is the Unix output? If two things aren't matching when they
should, the you have to look at both of them to make sure you're doing
it right. MD5 hashes are often stored in hex form, not base 64, for one
thing. (And yes, as pointed out, this has nothing to do with Unix shells.)

--
Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
Thousands have lived without love, not one without water.
-- W.H. Auden
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h33.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12259 seconds with 11 queries