Skip to content

Instantly share code, notes, and snippets.

View satyendrakumarsingh's full-sized avatar
🎯
Focusing

Satyendra Singh satyendrakumarsingh

🎯
Focusing
View GitHub Profile
@satyendrakumarsingh
satyendrakumarsingh / php hash_algos()
Last active May 28, 2016 09:55
PHP hash_algos() method print all the supported hash algorithm as of PHP 5.6.0
<?php
// Print all the supported hash algorithm as of PHP 5.6.0
// hash_algos() return array as result
print_r(hash_algos());
?>
@satyendrakumarsingh
satyendrakumarsingh / php hash_algos() list
Last active May 14, 2016 08:52
List of supported hash algorithms in PHP as of PHP 5.6.0
Array
(
[0] => md2
[1] => md4
[2] => md5
[3] => sha1
[4] => sha224
[5] => sha256
[6] => sha384
[7] => sha512
@satyendrakumarsingh
satyendrakumarsingh / php program to generate keyed hash value
Last active May 14, 2016 09:37
PHP function to generate hash value and compare two hash value
<?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);
}
@satyendrakumarsingh
satyendrakumarsingh / mysql-join-query-tips.sql
Last active September 6, 2021 07:01
MySQL Join Improvement
# 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;
@satyendrakumarsingh
satyendrakumarsingh / pluralsight-auto-next-module.js
Last active December 15, 2022 14:01
Pluralsight Auto Continue Script - Updated Script for Pluralsight Auto Next Module
let autoNext = () => {
Array.from(document.querySelectorAll('button'))
.filter(b => b.textContent === 'Continue to next module')
.forEach(b => b.click());
};
setInterval(autoNext, 2500);
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
@satyendrakumarsingh
satyendrakumarsingh / AESGCMUtility.cs
Created August 19, 2022 12:55
C# AES/GCM/NoPadding
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
<?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()
<?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);