This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Print all the supported hash algorithm as of PHP 5.6.0 | |
// hash_algos() return array as result | |
print_r(hash_algos()); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[0] => md2 | |
[1] => md4 | |
[2] => md5 | |
[3] => sha1 | |
[4] => sha224 | |
[5] => sha256 | |
[6] => sha384 | |
[7] => sha512 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Defining a generateHash PHP Function | |
function generateHash($algo, $data, $key) { | |
return hash_hmac($algo, $data, $key); | |
} | |
// Defining a compareHash PHP Function | |
function compareHash($hashValue1, $hashValue2) { | |
return hash_equals($hashValue1, $hashValue2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# QUERY WITH CONDITION IN WHERE CLUASE FOR JOINED TABLE | |
SELECT TAB_A.COL1, TAB_B.COL1 FROM TAB_A | |
LEFT OUTER JOIN TAB_B ON TAB_A.COL3 = TAB_B.COL3 | |
WHERE TAB_A.COL1=123 AND TAB_B.COL2=456; | |
# OPTIMIZED VERSION - MOVE JOINED TABLE CONDITION ALONG WITH JOIN CONDITION TO REDUCE ROW FILTERATION | |
SELECT TAB_A.COL1, TAB_B.COL1 FROM TAB_A | |
LEFT OUTER JOIN TAB_B ON TAB_A.COL3 = TAB_B.COL3 | |
AND TAB_B.COL2=456 | |
WHERE TAB_A.COL1=123; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let autoNext = () => { | |
Array.from(document.querySelectorAll('button')) | |
.filter(b => b.textContent === 'Continue to next module') | |
.forEach(b => b.click()); | |
}; | |
setInterval(autoNext, 2500); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Linq; | |
using Org.BouncyCastle.Crypto.Macs; | |
using Org.BouncyCastle.Crypto.Digests; | |
using Org.BouncyCastle.Crypto.Parameters; | |
/** | |
* Author: Satyendra Singh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Linq; | |
using Org.BouncyCastle.Crypto.Engines; | |
using Org.BouncyCastle.Crypto.Modes; | |
using Org.BouncyCastle.Crypto.Parameters; | |
/** | |
* Author: Satyendra Singh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AESGCMUtil { | |
const AES_KEY_SIZE = 256; // Key size for AES | |
const GCM_IV_LENGTH = 12; // IV length for GCM | |
const GCM_TAG_LENGTH = 16; // Authentication tag length for GCM | |
/** | |
* Prevent instantiation of the class. | |
*/ | |
private function __construct() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function generateHmacSha512($hmacData, $secretKey) { | |
$hmacValue = hash_hmac('sha512', $hmacData, pack('H*', $secretKey) , true); | |
return base64_encode($hmacValue); | |
} | |
# TEST HMACSHA512 FUNCTION | |
$hmacData = "satyendra"; | |
$secretKey = "6B58703273357638792F423F4528472B4B6250655368566D597133743677397A"; | |
echo generateHmacSha512($hmacData, $secretKey); |