PHP Registered Hashing Algorithms

PHP Registered Hashing Algorithms and their Hashed Value Length

PHP has a many hashing functions like sha1(), hash(), md5(), etc that can be used to hash a string/number based on certain algorithms i.e. “sha1”, “sha256”, “md5”, etc. You can use hash_algos() function to check a list of registered hashing algorithms. All these function takes a string/number as an argument and output an Alpha-Numeric hashed string of certain length. hash_algos() — Return a list of registered hashing algorithms. Currently PHP supports 46 hashing algorithms. hash_algos() function returns a numerically indexed array containing the list of supported hashing algorithms. Each hashing algorithm has a specific hashed value length. PHP Hash Algorithms Name & Length S.No. Algorithm Name Length 1 md2 32 2 md4 32 3 md5 32 4 sha1 40 5 …

Read More
Setup SSL On Localhost

How to add SSL/HTTPS to localhost WAMP Server

Install OpenSSL Download appropriate OpenSSL as per your windows bit (32-bit / 64-bit) from http://slproweb.com/products/Win32OpenSSL.html and install. While installing the setup it will ask you to select a directory for installation. You can install in any drive. So I am installing in my ‘E’ drive. You can read our article How to Install OpenSSL Light on Windows 10. And after install its path is E:\OpenSSL-Win64 Generate self-signed key and certificates for localhost Open E:\wamp64\bin\apache\apache2.4.33\conf\ folder and create a folder ‘ssl-certs’. Now, in cmd (Command Prompt) navigate to E:\wamp64\bin\apache\apache2.4.33\conf\ssl-certs directory and run following command. You can change the value for -days to the expiry days. I am creating certificates for the very long-term 😀

After certificates & key successfully created you should match …

Read More
Laravel

Laravel 5.7 HTTP URL Redirects

Today in this article we will discuss the HTTP URL Redirection in Laravel 5.7.  Laravel HTTP Redirect is an instance of Illuminate\Http\RedirectResponse class, which contains all necessary headers that needed to redirect the user to specific URL. Laravel provides many ways to generate RedirectResponse instance. redirect helper is the simplest way to redirect user to another URL. redirect helper is a global helper method. Redirect To URL in Laravel This is the simplest way to redirect the user to a particular URL.

Note: In the above example, If user hits the /dashboard URL then we are redirecting that user to new URL and that is /home/dashboard. Redirect Back To The Previous Page in Laravel Laravel is a very powerful PHP framework …

Read More
Laravel

Email Verification – New Feature of Laravel 5.7

Today, Laravel is a very powerful framework of PHP. Because of it’s vast available & scalable libraries/packages & developer’s full control on the project, It is now a new trend in PHP Web Development. On September 4th, 2018 Laravel has released it’s new edition i.e. Laravel 5.7 with some new features. Which make development more easy, fast and flexible. Laravel 5.7 Changes Log Laravel 5.7 continues the improvements made in Laravel 5.6 by introducing Laravel Nova. Optional email verification to the authentication scaffolding. Support for guest users in authorization gates and policies. Console testing improvements. Symfony dump-server integration. localizable notifications. Variety of ther bug fixes and usability improvements. Today, In this article we will discuss one of the new features of …

Read More
Coders Den

Get Mime Type of file without reading file metas

What is MIME Type? MIME stands for Multipurpose Internet Mail Extension. It is the standardized way to identify the nature and format of a document. It is defined and standardized in IETF RFC 6838. The Internet Assigned Numbers Authority (IANA) is the official body who is responsible for keeping track of all official MIME types, and you can find the most up-to-date and complete list at the Media Types page. Syntax of MIME Type type/subtype MIME type string is a combination of 2 strings that are Type & SubType separated by / symbol. There should not be any space between Type & SubType. Type is a category of multiple MIME types of common groups that are closely related to each other. SubType …

Read More
PHP Function

Get the Minimum & Maximum Sum of an array value in PHP

Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. For example,  arr = [1,3,5,7,9]. Our minimum sum is 1 + 3 + 5 + 7 = 16 and our maximum sum is 3 + 5 + 7 + 9 = 24 . We would print.

Function Description Complete the miniMaxSum function in the editor below. It should print two space-separated integers on one line: the minimum sum and the maximum sum of 4 of 5 elements. miniMaxSum has the following parameter(s): arr: an array of 5 integers Input Format …

Read More
PHP Function

Get 2D array’s diagonal values in PHP

Sometimes is programming line you may need diagonal values of a 2D array. Today in this article I will help you how you can get 2D array’s diagonal values in PHP programming language. Before the start, we should know the logic behind the function. Let suppose we have an array i.e.

Here, diagonal values will be. ar1 = 1,5,9 and ar2 = 3,5,7. We should check that array must be a square. If the input array is not a square we should throw an exception because error handling is the best practice. Here is the code that will fetch diagonal values from a 2D array in PHP. View the code on Gist.

Read More
PHP Function

Diagonal difference of 2D array – PHP

Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix arr is shown below:

The left-to-right diagonal = 1 + 5 + 9 = 15. The right to left diagonal = 3 + 5 + 9 = 17 . Their absolute difference is  |15 – 17| = 2. Function description Complete the diagnoalDifference  function in the editor below. It must return an integer representing the absolute diagonal difference. diagonalDifference takes the following parameter: arr: an array of integers . Input Format The first line contains a single integer, , the number of rows and columns in the matrix . Each of the next lines describes a row arr[I] , and consists of n space-separated …

Read More
function

Two strings, a and b, are said to be twins only if

Two strings, a and b, are said to be twins only if they can be made equivalent by performing some number of operations on one or both strings. There are two possible operations: SwapEven: Swap a character at an even-numbered index with a character at another even-numbered index. SwapOdd: Swap a character at an odd-numbered index with a character at another odd-numbered index. For example, a = “abcd” and b = “cdab” are twins because we can make them equivalent by performing operations. Alternatively, a = “abcd” and b = “bcda” are not twins (operations do not move characters between odd and even indices), and neither are a = “abc” and b = “ab” (no amount of operations will insert a ‘c’ into string b). Complete the twins function in the editor below. It has two parameters: An array of n strings named a. An …

Read More

What are traits in PHP OOPS / Laravel ?

What is Traits? Traits are a mechanism that allows you to create reusable code in languages like PHP where multiple inheritance is not supported. A Trait cannot be instantiated on its own. In layman language,  traits are simply a group of methods that you want to include within another class. A Trait is like an abstract class that cannot be instantiated by itself. The trait is created to reduce the limitations of single inheritance in PHP by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies. Example of Trait:

To use Trait within the other classes use use keyword with Trait name. i.e. user AbcClass;

Now if you create new objects …

Read More