สอบถามเรื่องการเข้ารหัสและการถอดรหัส สำหรับใช้กับรหัสผ่านของระบบ Login ครับ
ถ้าเป็นเจ้าของโค้ดเดิม แนะนำให้ไปดูโค้ดเดิม แล้วทำเลียนแบบครับ จะเป็นวิธีการที่ดีที่สุด
วิธีอื่นๆที่ทำได้หากเปลี่ยนมาใช้ PHP คือ ไม่ต้องสนใจว่าเขาเข้ารหัสยังไง แต่ ทำการเข้ารหัสใหม่เลย ด้วยวิธีของ PHP ซึ่งจะเสียเวลาน้อยที่สุด .... วิธีนี้มีข้อเสียข้อเดียวคือ user ทุกคนต้องทำการขอรหัสผ่านใหม่ แต่ก็ไม่ได้ยากอะไรครับ ถ้าเราเป็นเจ้าของเว็บจริงๆ
Date :
2016-08-21 16:13:38
By :
goragod
ตัวอย่าง Code เดิมครับ ขอยกตัวอย่างมาเฉพาะในส่วนของการ Encode และ Decode นะครับ
การเข้ารหัสแบบนี้สามารถแปลงเป็น PHP ได้มั้ยครับ พอดีไม่มีความรู้เรื่อง C# นะครับ
ขอบคุณครับ
Code (C#)
using System;
using System.Security.Cryptography;
using System.Text;
namespace SoftwareTest
{
/// <summary>
/// Summary description for Security.
/// </summary>
public class Security
{
public Security()
{
//
// TODO: Add constructor logic here
//
}
public static string Encrypt(string pCleanString) {
Byte[] clearBytes = new UnicodeEncoding().GetBytes(pCleanString);
Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
return BitConverter.ToString(hashedBytes);
}
public static string base64Encode(string data)
{
try
{
byte[] encData_byte = new byte[data.Length];
encData_byte = System.Text.Encoding.UTF8.GetBytes(data);
string encodedData = Convert.ToBase64String(encData_byte);
return encodedData;
}
catch(Exception e)
{
throw new Exception("Error in base64Encode" + e.Message);
}
}
public string base64Decode(string data)
{
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(data);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
string result = new String(decoded_char);
return result;
}
catch(Exception e)
{
throw new Exception("Error in base64Decode" + e.Message);
}
}
}
}
Date :
2016-08-22 10:39:00
By :
thanabordees93
เปลี่ยนวิธีการเป็น gen รหัสผ่านใหม่แล้วครับ ตอนนี้ติดปัญหาตรงส่งอีเมล์เพื่อยืนยันรหัสผ่านครับ
ผมเลือกใช้วิธีส่งจาก gmail แต่อีเมล์มันไม่เข้าครับ รบกวนช่วยดุโค๊ดให้ทีครับ
ขอบคุณครับ
Code (PHP)
require_once('PHPMailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "อีเมล์ที่ใช้ส่ง@gmail.com"; // GMAIL username
$mail->Password = "รหัสผ่าน Gmail"; // GMAIL password
$mail->From = "[email protected] "; // "[email protected] ";
$mail->FromName = "Mr.Tester"; // set from Name
$mail->Subject = "Test sending mail.";
$mail->Body = "My Body & <b>My Description</b>";
$mail->AddAddress("อีเมล์ผู้รับ@gmail.com", "Mr.Receive Tester"); // to Address
$mail->set('X-Priority', '1'); //Priority 1 = High, 3 = Normal, 5 = low
$mail->Send();
Date :
2016-08-23 11:32:00
By :
thanabordees93
1.อยู่ใน junk หรือเปล่า
2.delay หรือเปล่า บางที delay เป็นวันเลย
3.โดนบล๊อคหรือเปล่า gmail เรื่องเยอะ
4.ติดจำกัดการส่งหรือเปล่า gmail ฒันจำกัดการส่งต่อวัน
สาเหตุ เพียบ
ลองเปลี่ยนมาใช้ mailgun ดู
Date :
2016-08-23 15:42:26
By :
goragod
ปัจจุบัน php มีฟังก์ชั่นรองรับการ hash รหัสผ่าน แบบใหม่ๆแล้ว (PHP 5.5+, PHP 7) ซึ่งแข็งแกร่งกว่า md5 sha1 shaXXX เยอะแยะมาก
ถ้าเปลี่ยนแล้วก็อยากแนะนำให้ใช้ได้ถูกงานเพื่อความปลอดภัย
Date :
2016-08-23 20:06:09
By :
mr.v
บัญชีฟรีมันส่งตามคิวครับ อาจช้านิดนึง แต่เท่าที่ลอง มันก็ส่งได้ดีครับ
Date :
2016-08-24 12:17:45
By :
goragod
ถ้าจำไม่ผิด Mailgun อาจต้องลงทะเบียนชื่อผู้สง ก่อนครับ
Date :
2016-08-25 07:51:52
By :
goragod
Load balance : Server 03