Website Push Notification with Google Firebase

Mainly three things are needed A file named firebase-messaging-sw.js placed in the root of the website. This file contains the codes for receiving the push when the browser is minimized or that particular website is closed. The scripts for receiving the push The server side code to send the PUSH   firebase-messaging-sw.js Code for Receiving… Continue reading Website Push Notification with Google Firebase

Playing RTMP in Browser without FLASH

RTMP is used for streaming live video. With a bit of manipulation of the frontend codes it can also be used to play audio only (the below code does that) Now the thing is playing RTMP link in browser requires Flash which is not supported by Apple and Linux based OS. The solution is to… Continue reading Playing RTMP in Browser without FLASH

Two Way Encryption or Hashing using Key

This is using PHP and openssl_decrypt/openssl_encrypt Encrypting the string $key = “xxxxxxxxxxx”; //11 characters $ivlen = openssl_cipher_iv_length(“aes-256-cbc-hmac-sha256″); $iv = openssl_random_pseudo_bytes($ivlen); $hash = openssl_encrypt(STRING TO HASH,”aes-256-cbc-hmac-sha256”,$key,0,$iv); $iv = bin2hex($iv); // iv generated is in binary – converted to HEX for passing through SESSION or POST or URL Decrypting back the string $key = “xxxxxxxxxxx”; $hash =… Continue reading Two Way Encryption or Hashing using Key

PHP and MySQL – storing quotes

The best way to store quotes htmlentities($campaignsubject, ENT_QUOTES|ENT_SUBSTITUTE|ENT_HTML401); And to decode it back use html_entity_decode($rowsCampaigns[‘content’],ENT_QUOTES|ENT_SUBSTITUTE|ENT_HTML401);

PHP determine masked string

Here is a preg_match expression for finding if a string contains a certain set of repeated characters, say like the masking characters in a stored credit number or say a hidden phone number if(preg_match(“/x{5,12}/”,”THE STRING”))  // if there are 12 consecutive x in the string, starting from position 6