This file contains hidden or 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
| /** | |
| * SHA1 | |
| * Implementation of SHA1 algorithm as described in RFC 3174 | |
| * @see https://www.ietf.org/rfc/rfc3174.txt | |
| * | |
| * @param {string} string input to be hashed | |
| * @param {boolean} [raw=false] If the optional binary is set to true, then the sha1 digest is instead returned in raw binary format with a length of 20, otherwise the returned value is a 40-character hexadecimal number. | |
| * @return {string|false} Calculated the sha1 hash of a string, returning false if fail | |
| */ | |
| const sha1 = (string, raw = false) => { |
This file contains hidden or 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 | |
| declare(strict_types=1); | |
| class SemanticVersion implements JsonSerializable | |
| { | |
| /** | |
| * Regex pattern for semantic versioning | |
| * eg: | |
| * 1.2.3 | |
| * v1.2.3 |
This file contains hidden or 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
| /** | |
| * Fix base64 encode for javascript | |
| */ | |
| const base64_encode = (param) => { | |
| const convert_binary_str = (str) => { | |
| if (str.length < 1) { | |
| return ''; | |
| } | |
| let ord = str[0].charCodeAt(0); | |
| if (ord < 0) { |
This file contains hidden or 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
| export default class Ip { | |
| /** | |
| * IPv4 regex | |
| */ | |
| public static readonly IPv4_REGEX = /^(?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.(?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.(?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.(?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])$/; | |
| /** | |
| * IPv6 regex | |
| * ::1 is also valid IPv6 address | |
| */ | |
| public static readonly IPv6_REGEX = /^([0-9a-fA-F]{0,4}:){1,7}([0-9a-fA-F]{1,4})$/; |
This file contains hidden or 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
| /*! | |
| * IP Helper | |
| * | |
| * @author ArrayIterator<[email protected]> | |
| */ | |
| const IPv4_REGEX = /^(?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.(?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.(?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\.(?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])$/; | |
| // ::1 is also valid IPv6 address | |
| const IPv6_REGEX = /^([0-9a-fA-F]{0,4}:){1,7}([0-9a-fA-F]{1,4})$/; |
This file contains hidden or 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
| /** | |
| * Simple Password Strength Checker | |
| * ~ Password Score based on the following rules: | |
| * PasswordScore(password: string, username: string|null): number | |
| * ~ Generate Password based on the following rules: | |
| * GeneratePassword(length: number = 12): string | |
| * ~ Password Strength Level: | |
| * PASSWORD_WEAK: 0 | |
| * PASSWORD_MEDIUM: 1 | |
| * PASSWORD_STRONG: 2 |
This file contains hidden or 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
| const Algorithms = { | |
| AES: { | |
| description: 'Advanced Encryption Standard', | |
| ivLength: 16, | |
| decryptionSupported: true, | |
| keySupported: true, | |
| publicKeySupported: false, | |
| signatureSupported: false, | |
| default: 'AES-128-CBC', | |
| algorithms: { |
This file contains hidden or 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
| const createTrimRegexP = (e, position ='both') => { | |
| const charArray = {}; | |
| strval(e).split('').forEach((e) => { | |
| if (in_array(e, ['-', '/'])) { | |
| e = '\\' + e; | |
| } | |
| charArray[e] = e; | |
| }); | |
| let regex = `[${values(charArray).join('')}]`; | |
| switch (lower_trim(position)) { |
This file contains hidden or 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 | |
| declare(strict_types=1); | |
| namespace ArrayIterator\Hashing; | |
| use Exception; | |
| use function chr; | |
| use function crypt; | |
| use function max; | |
| use function min; |
This file contains hidden or 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
| // stpd! chatgpt 3.5 generated | |
| // phpDateConverter.js | |
| /** | |
| * Converts PHP date format to JavaScript date format. | |
| * @param {string} phpFormat - PHP date format string. | |
| * @returns {string} - JavaScript date format string. | |
| */ | |
| function convertPhpToJsDateFormat(phpFormat) { | |
| // Mapping of PHP date format characters to JavaScript equivalents |