In Python, there are 2 ways to make a list of alphabet characters.
Using string Module
The string.ascii_lowercase is a pre-initialized string used as string constant. In Python, string ascii_lowercase will give the lowercase letters ‘abcdefghijklmno...
In Golang, using the crypto/aes package is the easiest way to encrypt a string using AES CBC.
Ehrsam, Meyer, Smith and Tuchman invented the cipher block chaining (CBC) mode of operation in 1976. In CBC mode, each block of plaintext is XORed with the ...
In Golang, using the crypto/aes package is the easiest way to encrypt a string using AES GCM 256.
In cryptography, Galois/Counter Mode (GCM) is a mode of operation for symmetric-key cryptographic block ciphers which is widely adopted for its performa...
In Python, there are 2 ways to delete the contents of a folder.
Using rmtree Method
The shutil.rmtree() method deletes an entire directory tree; path must point to a directory. For example,
#!/usr/bin/python3
# Import module
import os, shutil
...
In Python, using the uuid module is the easiest way to create a GUID/UUID.
Using uuid Module
uuid module provides immutable UUID objects (the UUID class) and the functions uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5 UUID...
In Python, there are 2 ways to determine if an object is iterable.
Using Duck Typing
Duck typing is a concept related to dynamic typing, where the type or the class of an object is less important than the methods it defines. When you use duck typing...
In Golang, using the a case-insensitive flag is the easiest way to do a case insensitive regular expression.
Using a case-insensitive flag
You can set a case-insensitive flag as the first item in the regex.
You can add a (?i) at the beginning of th...
In Python, there are 3 ways to reverse a string.
Using slicing
Slice notation takes the form [start:stop:step].
#!/usr/bin/python3
s = "Hello World"
print(s[::-1])
# syntax
# a[start:stop] # items start through stop-1
# a[start:] # items...
In Rust, there are 3 ways to split a string.
Using split Function
An iterator over substrings of this string slice, separated by characters matched by a pattern. See the following example:
fn main() {
let s = "abc1bcd2e";
let _split = s.sp...
In Rust, variables by default are immutable.Variables Immutable
You can make them mutable by adding mut in front of the variable name. For example,
fn main() {
let x = 2;
println!("value x: {}", x);
x = 4;
println!("value x: {}", x);
}
...
In Rust, "Hello World!" is the first basic program.
Build and Run
In our main.rs, add the following code:
// main.rs
fn main() {
println!("Hello,世界,こんにちは,안녕하세요")
}
Hello,世界,こんにちは,안녕하세요
we can run our application by typing:
B...
In Rust, there are two ways to install rust in Linux.Running the following in your terminal
If you’re running macOS, Linux, or another Unix-like OS. To download Rustup and install Rust, run the following in your terminal, then follow the on-screen i...
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...
String Constants Best Practice.String Constants in Python
The constants defined in this module are:
String constants:
string.ascii_lettersThe concatenation of the ascii_lowercase and ascii_uppercase constants described below. This value is not locale...
Creating Random Strings of a fixed length in Go.
Using rand.Int63 Function
Int63 returns a non-negative pseudo-random 63-bit integer as an int64 from the default Source.
package main
import (
"fmt"
"math/rand"
"time"
)
const letters = "a...