walletservice/app/Traits/Helper.php

35 lines
955 B
PHP

<?php
namespace App\Traits;
use Illuminate\Support\Facades\Mail;
trait Helper
{
public function sendMail($email , $title , $messageText){
$recipients = [$email];
Mail::mailer('smtp')->raw($messageText, function ($message) use ($recipients,$title) {
$message->subject($title);
$message->to($recipients);
});
// return $this->successResponse("mail envoye");
}
public function checkPassword($password , $encrypted_password , $salt)
{
$encrypted_password_to_check = base64_encode(sha1($password . $salt, true) . $salt);
return $encrypted_password_to_check == $encrypted_password;
}
public function hashSSHA($string) {
$salt = sha1(rand());
$salt = substr($salt, 0, 10);
$encrypted = base64_encode(sha1($string . $salt, true) . $salt);
$hash = array("salt" => $salt, "encrypted" => $encrypted);
return $hash;
}
}