All Go Rust Python PHP JavaScript
Chrome Dev Summit to secure your spot in workshops, office hours and learning lounges!

How to Generate a SHA256 HMAC Hash from a String in Go

In Golang, using the crypto/hmac library is the easiest way to generate a SHA256 HMAC Hash from a string. In cryptography, an HMAC (hash-based message authentication code) is a specific type of message authentication code (MAC) involving a cryptograp...
ada

How to Get a SHA256 Hash from a String in Go

In Golang, using the Sum256 function is the easiest way to get a SHA256 hash from a string.Go implements several hash functions in various crypto/* packages. Using Sum256 Function The sha256.Sum256() function returns the SHA256 checksum of the data...
ada

How to Get a MD5 Hash from a String in Go

In Golang, using the Sum function is the easiest way to get a MD5 hash from a string. Using Sum Function The md5.Sum() function returns the MD5 checksum of the data. The following example should cover whatever you are trying to do: package mai...
aweis

How to Get the Full URL in PHP

In PHP, using the $_SERVER variable is the easiest way to get the full URL. Using $_SERVER Variable $_SERVER is an array containing information such as headers, paths, and script locations. The following example should cover whatever you are trying...
url
Sambhav Khandelwal

How to Iterate Over a String by Character in Rust

In Rust, there are 3 ways to iterate over a string by character. Using chars Method The chars() method returns an iterator over the chars of a string slice. See the following example: fn main() { let s = "abc"; for c in s.chars() { pr...
pooriabt

How to Update a Value in a Mutable HashMap in Rust

In Rust, there are 3 ways to update a value in a mutable HashMap. Using get_mut Method The get_mut() method returns a mutable reference to the value corresponding to the key. See the following example: use std::collections::HashMap; fn main()...
Unused

How to Count the Occurrences of a List Item in Python

In Python, there are 3 ways to count the occurrences of a list item. Using count Method The str.count() method returns the number of non-overlapping occurrences of substring sub in the range [start, end]. Optional arguments start and end are interpr...
Patcher56

How to Remove Duplicates Strings from Slice in Go

In Golang, there are 2 ways to remove duplicates strings from slice.Using a Hash Map We have defined a function where we are passing the slice values and using the map function we are checking the duplicates and removing them. The ones that are curr...
pooriabt

How to check if key exists in HashMap in Rust

In Rust, there are 2 ways to check if key exists in HashMap. Using HashMap::contains_key Method The contains_key method return true if the map contains a value for the specified key. use std::collections::HashMap; fn main() { let mut map = Hash...
Unused

How to create a multiline string in Rust

In Rust, there are 4 ways to create multiple lines string.Using triple-quotes A string literal is a sequence of any Unicode characters enclosed within two U+0022 (double-quote) characters, with the exception of U+0022 itself, which must be escaped b...
Unused

How to use hash function in Python

Secure hashes and message digests.Hash algorithms The hashlib module implements a common interface to many different secure hash and message digest algorithms. Included are the FIPS secure hash algorithms SHA1, SHA224, SHA256, SHA384, and SHA512 (def...
Unused

Built-in Types in Python

Python’s Core Data Types.Core Data Types The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. Built-in objects preview: Object type: Numbersint, float, complex.Strings'spam', "Bob's", b'a\x01c', u'sp\xc4m...
Unused

How to use of hash functions in PHP

How Hashing Function Works and its Syntax. MD5 Function The md5() calculates the md5 hash of a string. Returns the hash as a 32-character hexadecimal number. $str = "Google"; // 8b36e9207c24c76e6719268e49201d94 echo md5($str); // bool(true) md...
Tomoki

How to handle If-modified-since header in PHP

Reduce Bandwidth Usage by Supporting If-Modified-Since in PHP. If-Modified-Since The If-Modified-Since request HTTP header makes the request conditional: the server sends back the requested resource, with a 200 status, only if it has been last modif...
Patcher56

How to use the curl command in Linux

command line tool and library for transferring data with URLs. cURL (pronounced 'curl') is a computer software project providing a library (libcurl) and command-line tool (curl) for transferring data using various network protocols. The name ...