2012-03-09 73 views
0

我想在輸入數據庫之前將密碼的字符串轉換爲基本64,所以它會更安全。我可以做到嗎? 這裏從C#的.NET的例子:從字符串轉換爲基本64字符串JSP

字節[] enByte = ASCIIEncoding.ASCII.GetBytes(thepassword);

string lsPwd = Convert.ToBase64String(enByte);

+0

它**絕對**不會更安全。原始密碼仍可恢復。 – BalusC 2012-03-12 13:20:12

回答

1

我試過,它的工作,對不起我的帖子:)

DatatypeConverter DC = null來打擾你;
byte [] decodedBytes = vpass.getBytes();
String pass = dc.printBase64Binary(decodedBytes);

1

將其轉換爲Base64甚至不是安全的。使用散列法,最好使用random salt

+0

但我需要將其轉換回密碼,所以我需要2種方式的功能:)。你知道如何將字符串轉換爲JSP中的Base 64字符串嗎? – Nore 2012-03-09 07:29:26

+0

你爲什麼需要恢復密碼? – 2012-03-09 07:33:09

+0

當用戶忘記密碼時,我仍然可以恢復它 – Nore 2012-03-09 07:34:42