Salut,

J'ai une application java qui crypte des mots de passe dans une base de données en utilisant javax.crypto.Cipher :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
public String encrypt (String value)
	{
		String clearText = value;
		if (clearText == null)
			clearText = "";
		//	Init
		if (m_cipher == null)
			initCipher();
		//	Encrypt
		if (m_cipher != null)
		{
			try
			{
				m_cipher.init(Cipher.ENCRYPT_MODE, m_key);
				byte[] encBytes = m_cipher.doFinal(clearText.getBytes());
				String encString = convertToHexString(encBytes);
				log.log (Level.ALL, value + " => " + encString);
				return encString;
			}
			catch (Exception ex)
			{
				log.log(Level.INFO, value, ex);
			}
		}
		//	Fallback
		return CLEARVALUE_START + value + CLEARVALUE_END;
	}
private synchronized void initCipher()
	{
		if (m_cipher != null)
			return;
		Cipher cc = null;
		try
		{
			cc = Cipher.getInstance("DES/ECB/PKCS5Padding");
			m_key = SecureKey.key;
		}
		catch (Exception ex)
		{
			log.log(Level.SEVERE, "", ex);
		}
		m_cipher = cc;
	}	//	initCipher
Comment faire la même chose en PHP pour que le résultat crypté soit le même ?

Merci d'avance