Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > DES Encryption Java for the Basic authentication PHP

Reply
Thread Tools

DES Encryption Java for the Basic authentication PHP

 
 
Johnny
Guest
Posts: n/a
 
      11-02-2007
Hi,

I'm new of this group...

My name's Thomas.

I need an algorithm to encrypt a string with the DES encryption, that
works whit the basic auth in PHP.
I've tried some algorithms but the output don't works whit php....

May someone help me??

Thanks a lot everybody....

Bye

 
Reply With Quote
 
 
 
 
RedGrittyBrick
Guest
Posts: n/a
 
      11-02-2007
Johnny wrote:
> My name's Thomas.


Hmm.


>
> I need an algorithm to encrypt a string with the DES encryption, that
> works whit the basic auth in PHP.
> I've tried some algorithms but the output don't works whit php....
>


There's really only one algorithm for DES. It has several modes of
operation. Maybe you could find out which mode PHP uses?

http://www.itl.nist.gov/fipspubs/fip81.htm
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      11-02-2007
Johnny wrote:
>> My name's Thomas.


>> I need an algorithm to encrypt a string with the DES encryption, that
>> works whit the basic auth in PHP.
>> I've tried some algorithms but the output don't works whit php....


RedGrittyBrick wrote:
> There's really only one algorithm for DES. It has several modes of
> operation. Maybe you could find out which mode PHP uses?
>
> http://www.itl.nist.gov/fipspubs/fip81.htm


Thomas, please provide an SSCCE of the sort of thing you've tried.
<http://www.physci.org/codes/sscce.html>

--
Lew
 
Reply With Quote
 
Johnny
Guest
Posts: n/a
 
      11-02-2007
On Nov 2, 3:25 pm, Lew <l...@lewscanon.com> wrote:
> Johnny wrote:
> >> My name's Thomas.
> >> I need an algorithm to encrypt a string with the DES encryption, that
> >> works whit the basic auth in PHP.
> >> I've tried some algorithms but the output don't works whit php....

> RedGrittyBrick wrote:
> > There's really only one algorithm for DES. It has several modes of
> > operation. Maybe you could find out which mode PHP uses?

>
> >http://www.itl.nist.gov/fipspubs/fip81.htm

>
> Thomas, please provide an SSCCE of the sort of thing you've tried.
> <http://www.physci.org/codes/sscce.html>
>
> --
> Lew


------------------------------------------------------------

import javax.crypto.*;
public class DesEncrypter {
Cipher ecipher;
Cipher dcipher;

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) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
}
}

public String encrypt(String str) {
try {
// Encode the string into bytes using utf-8
byte[] utf8 = str.getBytes("UTF8");

// Encrypt
byte[] enc = ecipher.doFinal(utf;

// Encode bytes to base64 to get a string
return new sun.misc.BASE64Encoder().encode(enc);
} catch (javax.crypto.BadPaddingException e) {
} catch (IllegalBlockSizeException e) {
} catch (java.io.IOException e) {
}
return null;
}

public String decrypt(String str) {
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 new String(utf8, "UTF8");
} catch (javax.crypto.BadPaddingException e) {
} catch (IllegalBlockSizeException e) {
} catch (java.io.IOException e) {
}
return null;
}
public static void main(String args[]){
try {
SecretKey key =
KeyGenerator.getInstance("DES").generateKey();
DesEncrypter encrypter = new DesEncrypter(key);
System.out.println(encrypter.encrypt("ciao"));

} catch (Exception e) {
e.printStackTrace();
}

}

}

---------------------------------------------------------

This is the code i've founded on internet, i don't know if the output
is right or wrong, i only know that php basic auth don't works with
this encryption....

 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      11-03-2007
Johnny wrote:
> I need an algorithm to encrypt a string with the DES encryption, that
> works whit the basic auth in PHP.
> I've tried some algorithms but the output don't works whit php....


BASIC Authentication does not use DES.

It uses a simple Bse64 encoding of usernameassword !

Arne
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      11-03-2007
Arne Vajhøj wrote:
> Johnny wrote:
>> I need an algorithm to encrypt a string with the DES encryption, that
>> works whit the basic auth in PHP.
>> I've tried some algorithms but the output don't works whit php....

>
> BASIC Authentication does not use DES.
>
> It uses a simple Bse64 encoding of usernameassword !
>
> Arne

To clarify. Base authentication is not secure against eavesdropping or
packet sniffing.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
 
Reply With Quote
 
Johnny
Guest
Posts: n/a
 
      11-03-2007
On Nov 3, 1:17 am, Arne Vajhøj <a...@vajhoej.dk> wrote:
> Johnny wrote:
> > I need an algorithm to encrypt a string with the DES encryption, that
> > works whit the basic auth in PHP.
> > I've tried some algorithms but the output don't works whit php....

>
> BASIC Authentication does not use DES.
>
> It uses a simple Bse64 encoding of usernameassword !
>
> Arne


So, why here http://it2.php.net/crypt tell me that function crypt()
uses a standard DES encryption...

I need an algorithm to produce an encryption like this

lrB4D/h6wbVTM

to have this output i called this function

crypt("ciao","lr");

Thank you all.

 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      11-03-2007
Johnny wrote:
> On Nov 3, 1:17 am, Arne Vajhøj <a...@vajhoej.dk> wrote:
>> Johnny wrote:
>>> I need an algorithm to encrypt a string with the DES encryption, that
>>> works whit the basic auth in PHP.
>>> I've tried some algorithms but the output don't works whit php....

>> BASIC Authentication does not use DES.
>>
>> It uses a simple Bse64 encoding of usernameassword !

>
> So, why here http://it2.php.net/crypt tell me that function crypt()
> uses a standard DES encryption...


crypt uses DES, but crypt has nothing to do with Basic Authentication.

Arne

 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      11-03-2007
Johnny wrote:
> On Nov 3, 1:17 am, Arne Vajhøj <a...@vajhoej.dk> wrote:
>> Johnny wrote:
>>> I need an algorithm to encrypt a string with the DES encryption, that
>>> works whit the basic auth in PHP.
>>> I've tried some algorithms but the output don't works whit php....

>> BASIC Authentication does not use DES.
>>
>> It uses a simple Bse64 encoding of usernameassword !
>>
>> Arne

>
> So, why here http://it2.php.net/crypt tell me that function crypt()
> uses a standard DES encryption...
>
> I need an algorithm to produce an encryption like this
>
> lrB4D/h6wbVTM
>
> to have this output i called this function
>
> crypt("ciao","lr");


If you need the crypt functionality in Java then look at:

http://www.dynamic.net.au/christos/crypt/

crypt do use DES, but are not a simple DES.

http://en.wikipedia.org/wiki/Crypt_%28Unix%29

says:

#The traditional implementation uses a modified form of the DES
#algorithm. The user's password is truncated to eight characters, and
#those are coerced down to only 7-bits each; this forms the 56-bit DES
#key. That key is then used to encrypt an all-bits-zero block, and then
#the ciphertext is encrypted again with the same key, and so on for a
#total of 25 DES encryptions. A 12-bit salt is used to perturb the
#encryption algorithm, so standard DES implementations can't be used to
#implement crypt(). The salt and the final ciphertext are encoded into a
#printable string in a form of base 64.

Arne

 
Reply With Quote
 
Johnny
Guest
Posts: n/a
 
      11-03-2007
On Nov 3, 3:29 pm, Arne Vajhøj <a...@vajhoej.dk> wrote:
> Johnny wrote:
> > On Nov 3, 1:17 am, Arne Vajhøj <a...@vajhoej.dk> wrote:
> >> Johnny wrote:
> >>> I need an algorithm to encrypt a string with the DES encryption, that
> >>> works whit the basic auth in PHP.
> >>> I've tried some algorithms but the output don't works whit php....
> >> BASIC Authentication does not use DES.

>
> >> It uses a simple Bse64 encoding of usernameassword !

>
> > So, why herehttp://it2.php.net/crypttell me that function crypt()
> > uses a standard DES encryption...

>
> crypt uses DES, but crypt has nothing to do with Basic Authentication.
>
> Arne


Oh.... and what kind of encryption does the basic auth uses??

Thomas

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
I need Tripple DES encryption algorithm in C Dave Cullen C Programming 3 03-28-2007 09:31 PM
Config IPSEC for DES and 3DES Encryption mrpao Cisco 0 03-09-2007 04:10 AM
Python Translation of C# DES Encryption Andreas Pauley Python 4 05-15-2006 11:01 AM
javax.crypto: encrypte a string with Standard DES encryption with a 2-char SALT ClaudiaE Java 1 12-03-2003 06:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57