Skip to content

Commit 8ef9772

Browse files
Changed default signature hash type to md5
1 parent 1012e25 commit 8ef9772

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/Message/AbstractSignatureRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function getData(): array
2828

2929
$parameters = $this->getParameters();
3030
$parameters['vnp_SecureHash'] = $this->generateSignature(
31-
$parameters['vnp_SecureHashType'] = 'SHA256'
31+
$parameters['vnp_SecureHashType'] = 'md5'
3232
);
3333

3434
unset($parameters['vnp_HashSecret'], $parameters['testMode']);

src/Message/Concerns/RequestSignature.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trait RequestSignature
2121
* @param string $hashType
2222
* @return string
2323
*/
24-
protected function generateSignature($hashType = 'sha256'): string
24+
protected function generateSignature($hashType = 'md5'): string
2525
{
2626
$data = [];
2727
$signature = new Signature(

src/Support/Signature.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Signature
3636
* @param string $hashType
3737
* @throws InvalidArgumentException
3838
*/
39-
public function __construct(string $hashSecret, string $hashType = 'sha256')
39+
public function __construct(string $hashSecret, string $hashType = 'md5')
4040
{
4141
if (! $this->isSupportHashType($hashType)) {
4242
throw new InvalidArgumentException(sprintf('Hash type: `%s` is not supported by VNPay', $hashType));
@@ -57,9 +57,7 @@ public function generate(array $data): string
5757
ksort($data);
5858
$dataSign = $this->hashSecret.urldecode(http_build_query($data));
5959

60-
return strtoupper(
61-
hash($this->hashType, $dataSign)
62-
);
60+
return hash($this->hashType, $dataSign);
6361
}
6462

6563
/**

0 commit comments

Comments
 (0)