DATANAC

Binary
Decimal Binary
0 0
1 1
2 10
3 11
4 100
7 111
8 1000
10 1010
16 10000
20 10100

Addition

Binary addition follows the same rules as addition in the decimal system except that rather than carrying a 1 over when the values added equal 10, carry over occurs when the result of addition equals 2. Refer to the example below for clarification.

Note that in the binary system:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0, carry over the 1, i.e. 10

  10 11 11 10  1
+     1 0 1 1 1
=   1 0 0 1 0 0
Source
Binary arithmetic operators (Python oriented)
Priority Operator Name Example Meaning Result Result Type
Highest ** Exponentiation 2 ** 3 23 8 int if both arguments are ints
float otherwise
* Multiplication 2 * 3 2 × 3 6 int if both arguments are ints
float otherwise
/ Division 4 / 2 4 ÷ 2 2.0 always float
raises ZeroDivisionError when divisor is zero
// Integer division 5 // 2 2 int if both arguments are ints
float otherwise
raises ZeroDivisionError when divisor is zero
% Remainder (modulo) 5 % 2 5 mod 2 1 int if both arguments are ints
float otherwise
raises ZeroDivisionError when divisor is zero
+ Addition 2 + 1 2 + 1 3 int if both arguments are ints
float otherwise
Lowest - Subtraction 2 - 1 2 − 1 1 int if both arguments are ints
float otherwise
Modulo (Reminder) -> %
Derivative ƒ′(x)
Notation Name Description
ƒ′(x) 1st derivative (prime) Rate of change of ƒ at x
ƒ″(x) 2nd derivative (double prime) Rate of change of ƒ′ at x
ƒ‴(x) 3rd derivative (triple prime) Rate of change of ƒ″ at x
ƒ(n)(x) nth derivative nth‐order rate of change of ƒ at x
ƒ̇(x) Time derivative (dot) Derivative of ƒ with respect to time
ƒ̈(x) 2nd time derivative (double dot) Second derivative of ƒ with respect to time
∂ƒ(x)/∂x Partial derivative Rate of change of ƒ along one variable
∇ƒ(x) Gradient Vector of all partials of ƒ
∇²ƒ(x) Laplacian Divergence of ∇ƒ
dƒ(x)/dx Leibniz notation Derivative of ƒ with respect to x

An animation that provides an intuitive sense of the derivative, since a function’s “swing” changes when its input (argument) changes.


The derivative at different points of a differentiable function. In this case, the derivative is equal to


Online calculator
Pi π /paɪ/

The number pi (π) is a mathematical constant, approximately equal to 3.14159, that is the ratio of a circle's circumference to its diameter. It appears in many formulae across mathematics and physics, and some of these formulae are commonly used for defining π, to avoid relying on the definition of the length of a curve.


The brothers David and Gregory Volfovich Chudnovsky, born 1947 and 1952 respectively in Kyiv, Ukraine, are American mathematicians and engineers, who, in 1988 developped the ‘Chudnovsky Algorithm’ for the calculation of digits of π, based on Srinivasa Ramanujan’s π-formulae. The algorithm is based on the formula:


The Chudnovsky algorithm has been used for the World Record calculations of digits of π:

- 2.7 trillion digits in December 2009
- 10 trillion digits in October 2011
- 22.4 trillion digits in November 2016
- 31.4 trillion digits in September 2018–January 2019
- 50 trillion digits on January 29, 2020, and
- 62.8 trillion digits on August 14, 2021.

The last record, comprising exactly 62 831 853 071 794 digits (about 2π*10^13 digits), was achieved at the Computing Center of the University of Applied Sciences in Graubünden, Switzerland. The hardware used for the number crunching comprises two AMD CPUs with 32 cores each, 1 TB of RAM, and a massive 510 TB of storage space. The π digits alone took up 63 TB. All up, it took the team 108 days and nine hours to make the calculation.

Math
Cryptography
Concept Description
Symmetric encryption In this simple encryption method, only one secret key is used to both cipher and decipher information. Symmetric algorithms include AES-128, AES-192, and AES-256. Preferred for bulk data transmission due to speed and lower complexity.
Asymmetric encryption Also known as public key cryptography, uses a pair of related keys (one public, one private). The public key encrypts data, and the private key decrypts it. Underlies SSL/TLS certificates used by websites.
Data Encryption Standard (DES)
FIPS PUB 46-3

/*
 * Data Encryption Standard
 * An approach to DES algorithm
 * 
 * Based on the document FIPS PUB 46-3
 */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define LB32_MASK   0x00000001
#define LB64_MASK   0x0000000000000001
#define L64_MASK    0x00000000ffffffff
#define H64_MASK    0xffffffff00000000

/* Initial Permutation Table */
static char IP[] = {
    58, 50, 42, 34, 26, 18, 10,  2, 
    60, 52, 44, 36, 28, 20, 12,  4, 
    62, 54, 46, 38, 30, 22, 14,  6, 
    64, 56, 48, 40, 32, 24, 16,  8, 
    57, 49, 41, 33, 25, 17,  9,  1, 
    59, 51, 43, 35, 27, 19, 11,  3, 
    61, 53, 45, 37, 29, 21, 13,  5, 
    63, 55, 47, 39, 31, 23, 15,  7
};

/* Inverse Initial Permutation Table */
static char PI[] = {
    40,  8, 48, 16, 56, 24, 64, 32, 
    39,  7, 47, 15, 55, 23, 63, 31, 
    38,  6, 46, 14, 54, 22, 62, 30, 
    37,  5, 45, 13, 53, 21, 61, 29, 
    36,  4, 44, 12, 52, 20, 60, 28, 
    35,  3, 43, 11, 51, 19, 59, 27, 
    34,  2, 42, 10, 50, 18, 58, 26, 
    33,  1, 41,  9, 49, 17, 57, 25
};

/*Expansion table */
static char E[] = {
    32,  1,  2,  3,  4,  5,  
     4,  5,  6,  7,  8,  9,  
     8,  9, 10, 11, 12, 13, 
    12, 13, 14, 15, 16, 17, 
    16, 17, 18, 19, 20, 21, 
    20, 21, 22, 23, 24, 25, 
    24, 25, 26, 27, 28, 29, 
    28, 29, 30, 31, 32,  1
};

/* Post S-Box permutation */
static char P[] = {
    16,  7, 20, 21, 
    29, 12, 28, 17, 
     1, 15, 23, 26, 
     5, 18, 31, 10, 
     2,  8, 24, 14, 
    32, 27,  3,  9, 
    19, 13, 30,  6, 
    22, 11,  4, 25
};

/* The S-Box tables */
static char S[8][64] = {{
    /* S1 */
    14,  4, 13,  1,  2, 15, 11,  8,  3, 10,  6, 12,  5,  9,  0,  7,  
     0, 15,  7,  4, 14,  2, 13,  1, 10,  6, 12, 11,  9,  5,  3,  8,  
     4,  1, 14,  8, 13,  6,  2, 11, 15, 12,  9,  7,  3, 10,  5,  0, 
    15, 12,  8,  2,  4,  9,  1,  7,  5, 11,  3, 14, 10,  0,  6, 13
},{
    /* S2 */
    15,  1,  8, 14,  6, 11,  3,  4,  9,  7,  2, 13, 12,  0,  5, 10,  
     3, 13,  4,  7, 15,  2,  8, 14, 12,  0,  1, 10,  6,  9, 11,  5,  
     0, 14,  7, 11, 10,  4, 13,  1,  5,  8, 12,  6,  9,  3,  2, 15, 
    13,  8, 10,  1,  3, 15,  4,  2, 11,  6,  7, 12,  0,  5, 14,  9
},{
    /* S3 */
    10,  0,  9, 14,  6,  3, 15,  5,  1, 13, 12,  7, 11,  4,  2,  8,  
    13,  7,  0,  9,  3,  4,  6, 10,  2,  8,  5, 14, 12, 11, 15,  1,  
    13,  6,  4,  9,  8, 15,  3,  0, 11,  1,  2, 12,  5, 10, 14,  7,
     1, 10, 13,  0,  6,  9,  8,  7,  4, 15, 14,  3, 11,  5,  2, 12
},{
    /* S4 */
     7, 13, 14,  3,  0,  6,  9, 10,  1,  2,  8,  5, 11, 12,  4, 15,  
    13,  8, 11,  5,  6, 15,  0,  3,  4,  7,  2, 12,  1, 10, 14,  9,  
    10,  6,  9,  0, 12, 11,  7, 13, 15,  1,  3, 14,  5,  2,  8,  4,
     3, 15,  0,  6, 10,  1, 13,  8,  9,  4,  5, 11, 12,  7,  2, 14
},{
    /* S5 */
     2, 12,  4,  1,  7, 10, 11,  6,  8,  5,  3, 15, 13,  0, 14,  9, 
    14, 11,  2, 12,  4,  7, 13,  1,  5,  0, 15, 10,  3,  9,  8,  6, 
     4,  2,  1, 11, 10, 13,  7,  8, 15,  9, 12,  5,  6,  3,  0, 14, 
    11,  8, 12,  7,  1, 14,  2, 13,  6, 15,  0,  9, 10,  4,  5,  3
},{
    /* S6 */
    12,  1, 10, 15,  9,  2,  6,  8,  0, 13,  3,  4, 14,  7,  5, 11,
    10, 15,  4,  2,  7, 12,  9,  5,  6,  1, 13, 14,  0, 11,  3,  8,
     9, 14, 15,  5,  2,  8, 12,  3,  7,  0,  4, 10,  1, 13, 11,  6,
     4,  3,  2, 12,  9,  5, 15, 10, 11, 14,  1,  7,  6,  0,  8, 13
},{
    /* S7 */
     4, 11,  2, 14, 15,  0,  8, 13,  3, 12,  9,  7,  5, 10,  6,  1,
    13,  0, 11,  7,  4,  9,  1, 10, 14,  3,  5, 12,  2, 15,  8,  6,
     1,  4, 11, 13, 12,  3,  7, 14, 10, 15,  6,  8,  0,  5,  9,  2,
     6, 11, 13,  8,  1,  4, 10,  7,  9,  5,  0, 15, 14,  2,  3, 12
},{
    /* S8 */
    13,  2,  8,  4,  6, 15, 11,  1, 10,  9,  3, 14,  5,  0, 12,  7,
     1, 15, 13,  8, 10,  3,  7,  4, 12,  5,  6, 11,  0, 14,  9,  2,
     7, 11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8,
     2,  1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11
}};

/* Permuted Choice 1 Table */
static char PC1[] = {
    57, 49, 41, 33, 25, 17,  9,
     1, 58, 50, 42, 34, 26, 18,
    10,  2, 59, 51, 43, 35, 27,
    19, 11,  3, 60, 52, 44, 36,
    
    63, 55, 47, 39, 31, 23, 15,
     7, 62, 54, 46, 38, 30, 22,
    14,  6, 61, 53, 45, 37, 29,
    21, 13,  5, 28, 20, 12,  4
};

/* Permuted Choice 2 Table */
static char PC2[] = {
    14, 17, 11, 24,  1,  5,
     3, 28, 15,  6, 21, 10,
    23, 19, 12,  4, 26,  8,
    16,  7, 27, 20, 13,  2,
    41, 52, 31, 37, 47, 55,
    30, 40, 51, 45, 33, 48,
    44, 49, 39, 56, 34, 53,
    46, 42, 50, 36, 29, 32
};

/* Iteration Shift Array */
static char iteration_shift[] = {
 /* 1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16 */
    1,  1,  2,  2,  2,  2,  2,  2,  1,  2,  2,  2,  2,  2,  2,  1
};

/*
 * The DES function
 * input: 64 bit message
 * key: 64 bit key for encryption/decryption
 * mode: 'e' = encryption; 'd' = decryption
 */
uint64_t des(uint64_t input, uint64_t key, char mode) {
    
    int i, j;
    
    /* 8 bits */
    char row, column;
    
    /* 28 bits */
    uint32_t C                  = 0;
    uint32_t D                  = 0;
    
    /* 32 bits */
    uint32_t L                  = 0;
    uint32_t R                  = 0;
    uint32_t s_output           = 0;
    uint32_t f_function_res     = 0;
    uint32_t temp               = 0;
    
    /* 48 bits */
    uint64_t sub_key[16]        = {0};
    uint64_t s_input            = 0;
    
    /* 56 bits */
    uint64_t permuted_choice_1  = 0;
    uint64_t permuted_choice_2  = 0;
    
    /* 64 bits */
    uint64_t init_perm_res      = 0;
    uint64_t inv_init_perm_res  = 0;
    uint64_t pre_output         = 0;
    
    /* initial permutation */
    for (i = 0; i < 64; i++) {
        
        init_perm_res <<= 1;
        init_perm_res |= (input >> (64-IP[i])) & LB64_MASK;
        
    }
    
    L = (uint32_t) (init_perm_res >> 32) & L64_MASK;
    R = (uint32_t) init_perm_res & L64_MASK;
        
    /* initial key schedule calculation */
    for (i = 0; i < 56; i++) {
        
        permuted_choice_1 <<= 1;
        permuted_choice_1 |= (key >> (64-PC1[i])) & LB64_MASK;

    }
    
    C = (uint32_t) ((permuted_choice_1 >> 28) & 0x000000000fffffff);
    D = (uint32_t) (permuted_choice_1 & 0x000000000fffffff);
    
    /* Calculation of the 16 keys */
    for (i = 0; i< 16; i++) {
        
        /* key schedule */
        // shifting Ci and Di
        for (j = 0; j < iteration_shift[i]; j++) {
            
            C = 0x0fffffff & (C << 1) | 0x00000001 & (C >> 27);
            D = 0x0fffffff & (D << 1) | 0x00000001 & (D >> 27);
            
        }
        
        permuted_choice_2 = 0;
        permuted_choice_2 = (((uint64_t) C) << 28) | (uint64_t) D ;
        
        sub_key[i] = 0;
        
        for (j = 0; j < 48; j++) {
            
            sub_key[i] <<= 1;
            sub_key[i] |= (permuted_choice_2 >> (56-PC2[j])) & LB64_MASK;
            
        }
        
    }
    
    for (i = 0; i < 16; i++) {
        
        /* f(R,k) function */
        s_input = 0;
        
        for (j = 0; j< 48; j++) {
            
            s_input <<= 1;
            s_input |= (uint64_t) ((R >> (32-E[j])) & LB32_MASK);
            
        }
        
        /* 
         * Encryption/Decryption 
         * XORing expanded Ri with Ki
         */
        if (mode == 'd') {
            // decryption
            s_input = s_input ^ sub_key[15-i];
            
        } else {
            // encryption
            s_input = s_input ^ sub_key[i];
            
        }
        
        /* S-Box Tables */
        for (j = 0; j < 8; j++) {
            // 00 00 RCCC CR00 00 00 00 00 00 s_input
            // 00 00 1000 0100 00 00 00 00 00 row mask
            // 00 00 0111 1000 00 00 00 00 00 column mask
            
            row = (char) ((s_input & (0x0000840000000000 >> 6*j)) >> 42-6*j);
            row = (row >> 4) | row & 0x01;
            
            column = (char) ((s_input & (0x0000780000000000 >> 6*j)) >> 43-6*j);
            
            s_output <<= 4;
            s_output |= (uint32_t) (S[j][16*row + column] & 0x0f);
            
        }
        
        f_function_res = 0;
        
        for (j = 0; j < 32; j++) {
            
            f_function_res <<= 1;
            f_function_res |= (s_output >> (32 - P[j])) & LB32_MASK;
            
        }
        
        temp = R;
        R = L ^ f_function_res;
        L = temp;
        
    }
    
    pre_output = (((uint64_t) R) << 32) | (uint64_t) L;
        
    /* inverse initial permutation */
    for (i = 0; i < 64; i++) {
        
        inv_init_perm_res <<= 1;
        inv_init_perm_res |= (pre_output >> (64-PI[i])) & LB64_MASK;
        
    }
    
    return inv_init_perm_res;
    
}

int main(int argc, const char * argv[]) {

    int i;
    
    uint64_t input = 0x9474B8E8C73BCA7D;
    uint64_t key = 0x0000000000000000;
    uint64_t result = input;
    
    /*
     * TESTING IMPLEMENTATION OF DES
     * Ronald L. Rivest 
     * X0:  9474B8E8C73BCA7D
     * X16: 1B1A2DDB4C642438
     *
     * OUTPUT:
     * E: 8da744e0c94e5e17
     * D: 0cdb25e3ba3c6d79
     * E: 4784c4ba5006081f
     * D: 1cf1fc126f2ef842
     * E: e4be250042098d13
     * D: 7bfc5dc6adb5797c
     * E: 1ab3b4d82082fb28
     * D: c1576a14de707097
     * E: 739b68cd2e26782a
     * D: 2a59f0c464506edb
     * E: a5c39d4251f0a81e
     * D: 7239ac9a6107ddb1
     * E: 070cac8590241233
     * D: 78f87b6e3dfecf61
     * E: 95ec2578c2c433f0
     * D: 1b1a2ddb4c642438  <-- X16
     */
    for (i = 0; i < 16; i++) {
        
        if (i%2 == 0) {
            
            result = des(result, result, 'e');
            printf ("E: %016llx\n", result);
            
        } else {
            
            result = des(result, result, 'd');
            printf ("D: %016llx\n", result);
            
        }
    }
    
    //result = des(input, key, 'e');
    //printf ("E: %016llx\n", result);
    
    //result = des(result, key, 'd');
    //printf ("D: %016llx\n", result);
    
    exit(0);
    
}
                                    
A deprecated symmetric-key algorithm adopted in 1977 for U.S. government data. Uses the same key to encrypt and decrypt; superseded by AES due to security weaknesses.
Triple DES (3DES)
FIPS PUB 46-3

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include "3des.h"
/*
 * The DES function
 * input: 64 bit message
 * key: 64 bit key for encryption/decryption
 * mode: 'e' = encryption; 'd' = decryption
 */
uint64_t des(uint64_t input, uint64_t key, char mode) {
    
    int i, j;
    
    /* 8 bits */
    char row, column;
    
    /* 28 bits */
    uint32_t C                  = 0;
    uint32_t D                  = 0;
    
    /* 32 bits */
    uint32_t L                  = 0;
    uint32_t R                  = 0;
    uint32_t s_output           = 0;
    uint32_t f_function_res     = 0;
    uint32_t temp               = 0;
    
    /* 48 bits */
    uint64_t sub_key[16]        = {0};
    uint64_t s_input            = 0;
    
    /* 56 bits */
    uint64_t permuted_choice_1  = 0;
    uint64_t permuted_choice_2  = 0;
    
    /* 64 bits */
    uint64_t init_perm_res      = 0;
    uint64_t inv_init_perm_res  = 0;
    uint64_t pre_output         = 0;
    
    /* initial permutation */
    for (i = 0; i < 64; i++) {
        
        init_perm_res <<= 1;
        init_perm_res |= (input >> (64-IP[i])) & LB64_MASK;
        
    }
    
    L = (uint32_t) (init_perm_res >> 32) & L64_MASK;
    R = (uint32_t) init_perm_res & L64_MASK;
        
    /* initial key schedule calculation */
    for (i = 0; i < 56; i++) {
        
        permuted_choice_1 <<= 1;
        permuted_choice_1 |= (key >> (64-PC1[i])) & LB64_MASK;

    }
    
    C = (uint32_t) ((permuted_choice_1 >> 28) & 0x000000000fffffff);
    D = (uint32_t) (permuted_choice_1 & 0x000000000fffffff);
    
    /* Calculation of the 16 keys */
    for (i = 0; i< 16; i++) {
        
        /* key schedule */
        // shifting Ci and Di
        for (j = 0; j < iteration_shift[i]; j++) {
            
            C = 0x0fffffff & (C << 1) | 0x00000001 & (C >> 27);
            D = 0x0fffffff & (D << 1) | 0x00000001 & (D >> 27);
            
        }
        
        permuted_choice_2 = 0;
        permuted_choice_2 = (((uint64_t) C) << 28) | (uint64_t) D ;
        
        sub_key[i] = 0;
        
        for (j = 0; j < 48; j++) {
            
            sub_key[i] <<= 1;
            sub_key[i] |= (permuted_choice_2 >> (56-PC2[j])) & LB64_MASK;
            
        }
        
    }
    
    for (i = 0; i < 16; i++) {
        
        /* f(R,k) function */
        s_input = 0;
        
        for (j = 0; j< 48; j++) {
            
            s_input <<= 1;
            s_input |= (uint64_t) ((R >> (32-E[j])) & LB32_MASK);
            
        }
        
        /* 
         * Encryption/Decryption 
         * XORing expanded Ri with Ki
         */
        if (mode == 'd') {
            // decryption
            s_input = s_input ^ sub_key[15-i];
            
        } else {
            // encryption
            s_input = s_input ^ sub_key[i];
            
        }
        
        /* S-Box Tables */
        for (j = 0; j < 8; j++) {
            // 00 00 RCCC CR00 00 00 00 00 00 s_input
            // 00 00 1000 0100 00 00 00 00 00 row mask
            // 00 00 0111 1000 00 00 00 00 00 column mask
            
            row = (char) ((s_input & (0x0000840000000000 >> 6*j)) >> 42-6*j);
            row = (row >> 4) | row & 0x01;
            
            column = (char) ((s_input & (0x0000780000000000 >> 6*j)) >> 43-6*j);
            
            s_output <<= 4;
            s_output |= (uint32_t) (S[j][16*row + column] & 0x0f);
            
        }
        
        f_function_res = 0;
        
        for (j = 0; j < 32; j++) {
            
            f_function_res <<= 1;
            f_function_res |= (s_output >> (32 - P[j])) & LB32_MASK;
            
        }
        
        temp = R;
        R = L ^ f_function_res;
        L = temp;
        
    }
    
    pre_output = (((uint64_t) nR) << 32) | (uint64_t) L;
        
    /* inverse initial permutation */
    for (i = 0; i < 64; i++) {
        
        inv_init_perm_res <<= 1;
        inv_init_perm_res |= (pre_output >> (64-PI[i])) & LB64_MASK;
        
    }
    
    return inv_init_perm_res;
    
}
                                    
Runs the DES algorithm three times with three separate keys. Introduced as a stopgap measure when single-DES became too weak, prior to widespread AES adoption.
RSA

FIPS 186-5

/*
 * C program to Implement the RSA Algorithm
 */
 
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
long int p, q, n, t, flag, e[100], d[100], temp[100], j, m[100], en[100], i;
char msg[100];
int prime(long int);
void ce();
long int cd(long int);
void encrypt();
void decrypt();
void main()
{
    printf("\nENTER FIRST PRIME NUMBER\n");
    scanf("%d", &p);
    flag = prime(p);
    if (flag == 0)
    {
        printf("\nWRONG INPUT\n");
        getch();
        exit(1);
    }
    printf("\nENTER ANOTHER PRIME NUMBER\n");
    scanf("%d", &q);
    flag = prime(q);
    if (flag == 0 || p == q)
    {
        printf("\nWRONG INPUT\n");
        getch();
        exit(1);
    }
    printf("\nENTER MESSAGE\n");
    fflush(stdin);
    scanf("%s", msg);
    for (i = 0; msg[i] != NULL; i++)
        m[i] = msg[i];
    n = p * q;
    t = (p - 1) * (q - 1);
    ce();
    printf("\nPOSSIBLE VALUES OF e AND d ARE\n");
    for (i = 0; i < j - 1; i++)
        printf("\n%ld\t%ld", e[i], d[i]);
    encrypt();
    decrypt();
}
int prime(long int pr)
{
    int i;
    j = sqrt(pr);
    for (i = 2; i <= j; i++)
    {
        if (pr % i == 0)
            return 0;
    }
    return 1;
}
void ce()
{
    int k;
    k = 0;
    for (i = 2; i < t; i++)
    {
        if (t % i == 0)
            continue;
        flag = prime(i);
        if (flag == 1 && i != p && i != q)
        {
            e[k] = i;
            flag = cd(e[k]);
            if (flag > 0)
            {
                d[k] = flag;
                k++;
            }
            if (k == 99)
                break;
        }
    }
}
long int cd(long int x)
{
    long int k = 1;
    while (1)
    {
        k = k + t;
        if (k % x == 0)
            return (k / x);
    }
}
void encrypt()
{
    long int pt, ct, key = e[0], k, len;
    i = 0;
    len = strlen(msg);
    while (i != len)
    {
        pt = m[i];
        pt = pt - 96;
        k = 1;
        for (j = 0; j < key; j++)
        {
            k = k * pt;
            k = k % n;
        }
        temp[i] = k;
        ct = k + 96;
        en[i] = ct;
        i++;
    }
    en[i] = -1;
    printf("\nTHE ENCRYPTED MESSAGE IS\n");
    for (i = 0; en[i] != -1; i++)
        printf("%c", en[i]);
}
void decrypt()
{
    long int pt, ct, key = d[0], k;
    i = 0;
    while (en[i] != -1)
    {
        ct = temp[i];
        k = 1;
        for (j = 0; j < key; j++)
        {
            k = k * ct;
            k = k % n;
        }
        pt = k + 96;
        m[i] = pt;
        i++;
    }
    m[i] = -1;
    printf("\nTHE DECRYPTED MESSAGE IS\n");
    for (i = 0; m[i] != -1; i++)
        printf("%c", m[i]);
}
                                    
Rivest-Shamir-Adleman algorithm forming the basis of a public-key cryptosystem. Enables secure key exchange and digital signatures, widely used in VPNs and browser HTTPS connections.
Advanced Encryption Standard (AES)
FIPS 197

/*
 * Advanced Encryption Standard
 * Based on the document FIPS PUB 197
 */
#include "aes.h"
#include "gmult.h"

/*
 * Addition in GF(2^8)
 * http://en.wikipedia.org/wiki/Finite_field_arithmetic
 */
uint8_t gadd(uint8_t a, uint8_t b) {
	return a^b;
}

/*
 * Subtraction in GF(2^8)
 * http://en.wikipedia.org/wiki/Finite_field_arithmetic
 */
uint8_t gsub(uint8_t a, uint8_t b) {
	return a^b;
}

/*
 * Multiplication in GF(2^8)
 * http://en.wikipedia.org/wiki/Finite_field_arithmetic
 * Irreducible polynomial m(x) = x8 + x4 + x3 + x + 1
 *
 * NOTE: This function can be easily replaced with a look up table for a speed 
 *       boost, at the expense of an increase in memory size (around 65 KB). See
 *       the aes.h header file to find the macro definition.
uint8_t gmult(uint8_t a, uint8_t b) {

	uint8_t p = 0, i = 0, hbs = 0;

	for (i = 0; i < 8; i++) {
		if (b & 1) {
			p ^= a;
		}

		hbs = a & 0x80;
		a <<= 1;
		if (hbs) a ^= 0x1b; // 0000 0001 0001 1011	
		b >>= 1;
	}

	return (uint8_t)p;
}
*/

/*
 * Addition of 4 byte words
 * m(x) = x4+1
 */
void coef_add(uint8_t a[], uint8_t b[], uint8_t d[]) {

	d[0] = a[0]^b[0];
	d[1] = a[1]^b[1];
	d[2] = a[2]^b[2];
	d[3] = a[3]^b[3];
}

/*
 * Multiplication of 4 byte words
 * m(x) = x4+1
 */
void coef_mult(uint8_t *a, uint8_t *b, uint8_t *d) {

	d[0] = gmult(a[0],b[0])^gmult(a[3],b[1])^gmult(a[2],b[2])^gmult(a[1],b[3]);
	d[1] = gmult(a[1],b[0])^gmult(a[0],b[1])^gmult(a[3],b[2])^gmult(a[2],b[3]);
	d[2] = gmult(a[2],b[0])^gmult(a[1],b[1])^gmult(a[0],b[2])^gmult(a[3],b[3]);
	d[3] = gmult(a[3],b[0])^gmult(a[2],b[1])^gmult(a[1],b[2])^gmult(a[0],b[3]);
}

/*
 * The cipher Key.	
 */
int K;

/*
 * Number of columns (32-bit words) comprising the State. For this 
 * standard, Nb = 4.
 */
int Nb = 4;

/*
 * Number of 32-bit words comprising the Cipher Key. For this 
 * standard, Nk = 4, 6, or 8.
 */
int Nk;

/*
 * Number of rounds, which is a function of  Nk  and  Nb (which is 
 * fixed). For this standard, Nr = 10, 12, or 14.
 */
int Nr;

/*
 * S-box transformation table
 */
static uint8_t s_box[256] = {
	// 0     1     2     3     4     5     6     7     8     9     a     b     c     d     e     f
	0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, // 0
	0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, // 1
	0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, // 2
	0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, // 3
	0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, // 4
	0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, // 5
	0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, // 6
	0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, // 7
	0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, // 8
	0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, // 9
	0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, // a
	0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, // b
	0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, // c
	0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, // d
	0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, // e
	0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16};// f

/*
 * Inverse S-box transformation table
 */
static uint8_t inv_s_box[256] = {
	// 0     1     2     3     4     5     6     7     8     9     a     b     c     d     e     f
	0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, // 0
	0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, // 1
	0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, // 2
	0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, // 3
	0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, // 4
	0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, // 5
	0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, // 6
	0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, // 7
	0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, // 8
	0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, // 9
	0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, // a
	0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, // b
	0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, // c
	0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, // d
	0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, // e
	0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d};// f


/*
 * Generates the round constant Rcon[i]
 */
uint8_t R[] = {0x02, 0x00, 0x00, 0x00};
 
uint8_t * Rcon(uint8_t i) {
	
	if (i == 1) {
		R[0] = 0x01; // x^(1-1) = x^0 = 1
	} else if (i > 1) {
		R[0] = 0x02;
		i--;
		while (i > 1) {
			R[0] = gmult(R[0], 0x02);
			i--;
		}
	}
	
	return R;
}

/*
 * Transformation in the Cipher and Inverse Cipher in which a Round 
 * Key is added to the State using an XOR operation. The length of a 
 * Round Key equals the size of the State (i.e., for Nb = 4, the Round 
 * Key length equals 128 bits/16 bytes).
 */
void add_round_key(uint8_t *state, uint8_t *w, uint8_t r) {
	
	uint8_t c;
	
	for (c = 0; c < Nb; c++) {
		state[Nb*0+c] = state[Nb*0+c]^w[4*Nb*r+4*c+0];   //debug, so it works for Nb !=4 
		state[Nb*1+c] = state[Nb*1+c]^w[4*Nb*r+4*c+1];
		state[Nb*2+c] = state[Nb*2+c]^w[4*Nb*r+4*c+2];
		state[Nb*3+c] = state[Nb*3+c]^w[4*Nb*r+4*c+3];	
	}
}

/*
 * Transformation in the Cipher that takes all of the columns of the 
 * State and mixes their data (independently of one another) to 
 * produce new columns.
 */
void mix_columns(uint8_t *state) {

	uint8_t a[] = {0x02, 0x01, 0x01, 0x03}; // a(x) = {02} + {01}x + {01}x2 + {03}x3
	uint8_t i, j, col[4], res[4];

	for (j = 0; j < Nb; j++) {
		for (i = 0; i < 4; i++) {
			col[i] = state[Nb*i+j];
		}

		coef_mult(a, col, res);

		for (i = 0; i < 4; i++) {
			state[Nb*i+j] = res[i];
		}
	}
}

/*
 * Transformation in the Inverse Cipher that is the inverse of 
 * MixColumns().
 */
void inv_mix_columns(uint8_t *state) {

	uint8_t a[] = {0x0e, 0x09, 0x0d, 0x0b}; // a(x) = {0e} + {09}x + {0d}x2 + {0b}x3
	uint8_t i, j, col[4], res[4];

	for (j = 0; j < Nb; j++) {
		for (i = 0; i < 4; i++) {
			col[i] = state[Nb*i+j];
		}

		coef_mult(a, col, res);

		for (i = 0; i < 4; i++) {
			state[Nb*i+j] = res[i];
		}
	}
}

/*
 * Transformation in the Cipher that processes the State by cyclically 
 * shifting the last three rows of the State by different offsets. 
 */
void shift_rows(uint8_t *state) {

	uint8_t i, k, s, tmp;

	for (i = 1; i < 4; i++) {
		// shift(1,4)=1; shift(2,4)=2; shift(3,4)=3
		// shift(r, 4) = r;
		s = 0;
		while (s < i) {
			tmp = state[Nb*i+0];
			
			for (k = 1; k < Nb; k++) {
				state[Nb*i+k-1] = state[Nb*i+k];
			}

			state[Nb*i+Nb-1] = tmp;
			s++;
		}
	}
}

/*
 * Transformation in the Inverse Cipher that is the inverse of 
 * ShiftRows().
 */
void inv_shift_rows(uint8_t *state) {

	uint8_t i, k, s, tmp;

	for (i = 1; i < 4; i++) {
		s = 0;
		while (s < i) {
			tmp = state[Nb*i+Nb-1];
			
			for (k = Nb-1; k > 0; k--) {
				state[Nb*i+k] = state[Nb*i+k-1];
			}

			state[Nb*i+0] = tmp;
			s++;
		}
	}
}

/*
 * Transformation in the Cipher that processes the State using a non­
 * linear byte substitution table (S-box) that operates on each of the 
 * State bytes independently. 
 */
void sub_bytes(uint8_t *state) {

	uint8_t i, j;
	
	for (i = 0; i < 4; i++) {
		for (j = 0; j < Nb; j++) {
			// s_box row: yyyy ----
			// s_box col: ---- xxxx
			// s_box[16*(yyyy) + xxxx] == s_box[yyyyxxxx]
			state[Nb*i+j] = s_box[state[Nb*i+j]];
		}
	}
}

/*
 * Transformation in the Inverse Cipher that is the inverse of 
 * SubBytes().
 */
void inv_sub_bytes(uint8_t *state) {

	uint8_t i, j;

	for (i = 0; i < 4; i++) {
		for (j = 0; j < Nb; j++) {
			state[Nb*i+j] = inv_s_box[state[Nb*i+j]];
		}
	}
}

/*
 * Function used in the Key Expansion routine that takes a four-byte 
 * input word and applies an S-box to each of the four bytes to 
 * produce an output word.
 */
void sub_word(uint8_t *w) {

	uint8_t i;

	for (i = 0; i < 4; i++) {
		w[i] = s_box[w[i]];
	}
}

/*
 * Function used in the Key Expansion routine that takes a four-byte 
 * word and performs a cyclic permutation. 
 */
void rot_word(uint8_t *w) {

	uint8_t tmp;
	uint8_t i;

	tmp = w[0];

	for (i = 0; i < 3; i++) {
		w[i] = w[i+1];
	}

	w[3] = tmp;
}

/*
 * Key Expansion
 */
void aes_key_expansion(uint8_t *key, uint8_t *w) {

	uint8_t tmp[4];
	uint8_t i;
	uint8_t len = Nb*(Nr+1);

	for (i = 0; i < Nk; i++) {
		w[4*i+0] = key[4*i+0];
		w[4*i+1] = key[4*i+1];
		w[4*i+2] = key[4*i+2];
		w[4*i+3] = key[4*i+3];
	}

	for (i = Nk; i < len; i++) {
		tmp[0] = w[4*(i-1)+0];
		tmp[1] = w[4*(i-1)+1];
		tmp[2] = w[4*(i-1)+2];
		tmp[3] = w[4*(i-1)+3];

		if (i%Nk == 0) {

			rot_word(tmp);
			sub_word(tmp);
			coef_add(tmp, Rcon(i/Nk), tmp);

		} else if (Nk > 6 && i%Nk == 4) {

			sub_word(tmp);

		}

		w[4*i+0] = w[4*(i-Nk)+0]^tmp[0];
		w[4*i+1] = w[4*(i-Nk)+1]^tmp[1];
		w[4*i+2] = w[4*(i-Nk)+2]^tmp[2];
		w[4*i+3] = w[4*(i-Nk)+3]^tmp[3];
	}
}


/*
 * Initialize AES variables and allocate memory for expanded key
 */
uint8_t *aes_init(size_t key_size) {

        switch (key_size) {
		default:
		case 16: Nk = 4; Nr = 10; break;
		case 24: Nk = 6; Nr = 12; break;
		case 32: Nk = 8; Nr = 14; break;
	}

	return malloc(Nb*(Nr+1)*4);
}

/*
 * Performs the AES cipher operation
 */
void aes_cipher(uint8_t *in, uint8_t *out, uint8_t *w) {

	uint8_t state[4*Nb];
	uint8_t r, i, j;

	for (i = 0; i < 4; i++) {
		for (j = 0; j < Nb; j++) {
			state[Nb*i+j] = in[i+4*j];
		}
	}

	add_round_key(state, w, 0);

	for (r = 1; r < Nr; r++) {
		sub_bytes(state);
		shift_rows(state);
		mix_columns(state);
		add_round_key(state, w, r);
	}

	sub_bytes(state);
	shift_rows(state);
	add_round_key(state, w, Nr);

	for (i = 0; i < 4; i++) {
		for (j = 0; j < Nb; j++) {
			out[i+4*j] = state[Nb*i+j];
		}
	}
}

/*
 * Performs the AES inverse cipher operation
 */
void aes_inv_cipher(uint8_t *in, uint8_t *out, uint8_t *w) {

	uint8_t state[4*Nb];
	uint8_t r, i, j;

	for (i = 0; i < 4; i++) {
		for (j = 0; j < Nb; j++) {
			state[Nb*i+j] = in[i+4*j];
		}
	}

	add_round_key(state, w, Nr);

	for (r = Nr-1; r >= 1; r--) {
		inv_shift_rows(state);
		inv_sub_bytes(state);
		add_round_key(state, w, r);
		inv_mix_columns(state);
	}

	inv_shift_rows(state);
	inv_sub_bytes(state);
	add_round_key(state, w, 0);

	for (i = 0; i < 4; i++) {
		for (j = 0; j < Nb; j++) {
			out[i+4*j] = state[Nb*i+j];
		}
	}
}
                                    
Selected by NIST in 2001 as the successor to DES. A block cipher supporting 128-, 192-, and 256-bit keys. Ubiquitous for protecting data at rest and in transit.
Encryption in the cloud Cloud providers encrypt customer data before storage. Models include BYOE (bring your own encryption keys) and EaaS (Encryption as a Service) to meet varying security requirements.
End-to-End encryption (E2EE) Ensures only the communicating endpoints can decrypt messages. Even intermediaries (ISPs, telecoms) cannot read the content. Used by services like WhatsApp for private messaging.


SP 800 Series

SP 800 Number Title / Focus Description
SP 800-38 series Block-cipher Modes of Operation
  • SP 800-38A: ECB, CBC, CFB, OFB, CTR
  • SP 800-38B: CMAC
  • SP 800-38C: CCM
  • SP 800-38D: GCM
  • SP 800-38F: AES key-wrap
  • SP 800-38G: Format-Preserving Encryption
SP 800-67 Triple Data Encryption Algorithm (TDEA) Guidance on 2- and 3-key Triple-DES for federal use
SP 800-56 series Key-Establishment Schemes
  • SP 800-56A: Diffie-Hellman
  • SP 800-56B: RSA key transport
  • SP 800-56C: Generic key-transport schemes
SP 800-57 parts 1–3 Key Management
  • Part 1: Principles & terminology
  • Part 2: Organizational best practices
  • Part 3: Application-specific key management
SP 800-90 series Random Number Generation
  • SP 800-90A: Hash/HMAC/CTR-based DRBGs
  • SP 800-90B: Entropy source requirements
  • SP 800-90C: Combining entropy & DRBGs
SP 800-131A Transitioning Cryptographic Algorithms Guidance on phasing out deprecated algorithms & key lengths
SP 800-108 Key Derivation Functions Recommendations for KDF constructions (e.g. counter-mode KDF)
SP 800-175B Use of Crypto Standards in Federal Systems Implementation guidance for NIST-approved cryptography
SP 800-133 Cryptographic Key Generation Best practices for generating secure cryptographic keys


Acronym Description
AES Advanced Encryption Standard
BYOE Bring Your Own Encryption keys
CBC Cipher Block Chaining
CCM Counter with CBC-MAC
CMAC Cipher-based Message Authentication Code
CFB Cipher Feedback
CTR Counter mode
DES Data Encryption Standard
3DES Triple DES (applies DES three times)
DRBG Deterministic Random Bit Generator
E2EE End-to-End Encryption
EaaS Encryption as a Service
ECB Electronic Codebook
FIPS Federal Information Processing Standards
GCM Galois/Counter Mode
HMAC Hash-based Message Authentication Code
HTTPS Hypertext Transfer Protocol Secure
ISP Internet Service Provider
IDS Intrusion Detection System
IPS Intrusion Prevention System
IDPS Intrusion Detection and Prevention System
NIDS Network Intrusion Detection System
NIPS Network Intrusion Prevention System
NIDPS Network Intrusion Detection and Prevention System
HIDS Host-based Intrusion Detection System
HIPS Host-based Intrusion Prevention System
HIDPS Host-based Intrusion Detection and Prevention System
KDF Key Derivation Function
NIST National Institute of Standards and Technology
OFB Output Feedback
RSA Rivest–Shamir–Adleman
SDC Secure Data Communications
SP Special Publication (NIST)
TDEA Triple Data Encryption Algorithm
TLS Transport Layer Security
VPN Virtual Private Network
Programming and OOP

Programming languages timeline


Programming languages

Year Language Creator Type Description Example
1945 Plankalkül Konrad Zuse Procedural / Algorithmic First high-level programming language, designed for engineering/scientific calculations; introduced arrays, records and structured data. V0 ← 0
FOR I ← 1 TO N DO
V0 ← V0 + A[I]
END
1949 Short Code John Mauchly Interpreted One of the very first high-level languages (for UNIVAC I); used alphanumeric tokens to express arithmetic and logical operations, with a runtime translator converting them into machine code. S = A + B * C
PRINT S
1952 Autocode Alick Glennie Procedural (Compiled) One of the first high-level compiled languages for the Manchester Mark I, using mnemonic codes to represent arithmetic and memory operations. LOAD A
ADD B
STORE C
PRINT C
1957 FORTRAN John Backus Procedural (Compiled) First high-level programming language, optimized for numeric and scientific computing; introduced the concept of compiling human-readable code into efficient machine instructions. PRINT *, "Hello, World!"
1959 FLOW-MATIC Grace Hopper & Remington Rand Procedural (Interpreted) First English-like data processing language for business applications; directly influenced the development of COBOL. COMPUTE TOTAL = PRICE * QUANTITY
DISPLAY TOTAL
1958 LISP John McCarthy Functional Pioneered list processing, symbolic computation, and recursion. (print "Hello, World!")
1958 ALGOL IFIP/POPP Procedural Introduced block structure and lexical scope; basis for many later languages. begin print("Hello, World!"); end;
1959 COBOL Grace Hopper & CODASYL (Conference on Data Systems Languages) Procedural Designed for business data processing with English-like syntax. DISPLAY "Hello, World!".
1964 BASIC John Kemeny & Thomas Kurtz Procedural / Interpreted Beginner’s All-purpose Symbolic Instruction Code; designed for easy use by students in interactive time-sharing. PRINT "Hello, World!"
1964 PL/I IBM Procedural / Multi-paradigm Combined features of scientific (FORTRAN) and business (COBOL) languages into a universal programming language. PUT SKIP LIST('Hello, World!');
1967 Simula Ole-Johan Dahl & Kristen Nygaard Object-oriented / Simulation First object-oriented language; introduced classes, objects, and inheritance for simulation modeling. OutText("Hello, World!");
OutImage;
1970 Pascal Niklaus Wirth Procedural (Compiled) Created for teaching structured programming and data structures; enforces strong typing and block structure. writeln('Hello, World!');
1972 Prolog Alain Colmerauer & Robert Kowalski Logic Logic programming language for symbolic computation and artificial intelligence; programs consist of facts and rules. ?- write('Hello, World!').
1972 Smalltalk Alan Kay, Dan Ingalls & Adele Goldberg Object-oriented Pure object-oriented language where everything is an object; pioneered MVC and live programming environments. Transcript show: 'Hello, World!'.
1972 C Dennis Ritchie Procedural (Compiled) Systems programming language offering low-level access to memory, simple syntax, and efficient compiled code. #include <stdio.h>
int main() {
  printf("Hello, World!\\n");
  return 0;
}
1974 SQL Donald D. Chamberlin & Raymond F. Boyce Declarative / Query Standard language for defining, manipulating, and querying relational databases using set-based operations. SELECT 'Hello, World!';
1980 Ada Jean Ichbiah Procedural / Structured / Concurrent Designed by the DoD for embedded and real-time systems; strong typing, modularity, and built-in concurrency. with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
  begin
    Put_Line("Hello, World!");
end Hello;
1984 MATLAB Cleve Moler Procedural / Numeric High-level language and environment for numerical computing, visualization, and programming; emphasizes matrix and linear algebra operations. disp('Hello, World!');
1984 Objective-C Brad Cox & Tom Love Object-oriented / Dynamic Superset of C adding Smalltalk-style messaging and dynamic runtime features. #import <Foundation/Foundation.h>
int main() {
  NSLog(@"Hello, World!");
  return 0;
}
1985 C++ Bjarne Stroustrup Multi-paradigm (Object-oriented, Generic) Extension of C with classes, templates, and exception handling; supports generic, object-oriented, and functional programming styles. #include <iostream>
int main() {
  std::cout << "Hello, World!";
  return 0;
}
1987 Perl Larry Wall Scripting / Dynamic Practical Extraction and Report Language; excels at text processing with built-in regular expressions. print "Hello, World!\n";
1990 Haskell Haskell Committee (Simon Peyton Jones, Philip Wadler, et al.) Functional Standardized purely functional, lazy language with strong static typing and type inference. main = putStrLn "Hello, World!"
1991 Python Guido van Rossum Multi-paradigm (Object-oriented, Imperative, Functional) Emphasizes readability, simplicity, and a vast standard library; widely used for automation, web development, and data science. print("Hello, World!")
1991 Visual Basic Alan Cooper & Microsoft Event-driven / RAD Designed for rapid application development of graphical user interfaces on Windows. MsgBox "Hello, World!"
1993 R Ross Ihaka & Robert Gentleman Statistical / Functional Language and environment for statistical computing and graphics; widely used for data analysis and visualization. print("Hello, World!")
1995 Ruby Yukihiro “Matz” Matsumoto Multi-paradigm (Object-oriented, Functional) Dynamic, reflective language designed for programmer happiness; everything is an object. puts "Hello, World!"
1995 Java James Gosling & Sun Microsystems Object-oriented (Class-based) “Write Once, Run Anywhere” language executed on the Java Virtual Machine; strong static typing. System.out.println("Hello, World!");
1995 JavaScript Brendan Eich & Netscape Multi-paradigm (Event-driven, Functional, Prototype-based) Client-side scripting language for the web; first-class functions and dynamic typing. console.log("Hello, World!");
1995 PHP Rasmus Lerdorf Scripting (Server-side) Embedded web scripting language for creating dynamic pages; later evolved into a full-featured general-purpose language. <?php echo "Hello, World!"; ?>
1996 ActionScript Macromedia Scripting (ECMAScript-based) Client-side scripting language for Adobe Flash; adds interactivity and animation to multimedia content. trace("Hello, World!");
2000 C# Anders Hejlsberg & Microsoft Multi-paradigm (Object-oriented, Component-oriented) Developed by Microsoft for the .NET framework; strongly-typed, component-oriented language for building enterprise and desktop applications. using System;
class Program {
  static void Main() {
    Console.WriteLine("Hello, World!");
  }
}
2001 D Walter Bright Multi-paradigm (Systems, Object-oriented) Combines the performance of C++ with modern features like garbage collection, design-by-contract, and simplified syntax. import std.stdio;
void main() {
  writeln("Hello, World!");
}
2003 Groovy James Strachan & Apache Multi-paradigm (Object-oriented, Scripting) Dynamic language for the JVM with concise syntax, closures, and powerful DSL capabilities. println 'Hello, World!'
2004 Scala Martin Odersky Multi-paradigm (Functional, Object-oriented) Combines object-oriented and functional programming in a concise, statically-typed language on the JVM. object HelloWorld extends App { println("Hello, World!") }
2007 Scratch MIT Media Lab Visual (Educational) Block-based language designed to teach coding concepts through interactive animations and games. when green flag clicked
say "Hello, World!" for 2 seconds
2007 Clojure Rich Hickey Functional (Lisp dialect) Modern Lisp dialect on the JVM emphasizing immutability, concurrency, and functional programming. (println "Hello, World!")
2009 Go Rob Pike, Ken Thompson & Robert Griesemer Concurrent / Compiled Designed at Google for simplicity, fast compilation, and built-in concurrency with goroutines and channels. fmt.Println("Hello, World!")
2010 Rust Graydon Hoare & Mozilla Systems / Multi-paradigm Focuses on memory safety without garbage collection, using ownership and borrowing to prevent data races. println!("Hello, World!");
2011 Dart Lars Bak & Kasper Lund (Google) Object-oriented / Compiled Optimized for client-side development—web & mobile—with both ahead-of-time and just-in-time compilation. void main() => print('Hello, World!');
2011 Kotlin JetBrains (Andrey Breslav lead) Statically-typed / JVM & Multi-platform Concise, null-safe language for the JVM and beyond; features type inference, coroutines, and seamless Java interop. fun main() { println("Hello, World!") }
2014 Swift Apple (Chris Lattner lead) Compiled / Multi-paradigm Modern language for iOS/macOS development with safety features (optionals, strict typing), fast performance, and expressive syntax. print("Hello, World!")


OOP base concepts



OOP implementation



OOP pillars

Control Logic

Logic Gates

Symbol Name Description Algorithmic expression Truth Table
AND gate symbol AND Outputs 1 only if both inputs are 1. AND operator expression AND truth table
OR gate symbol OR Outputs 1 if at least one input is 1. OR operator expression OR truth table
NOT gate symbol NOT Inverts the input (0 → 1, 1 → 0). NOT operator expression NOT truth table
NAND gate symbol NAND Outputs 0 only if both inputs are 1 (inverse of AND). NAND operator expression NAND truth table
NOR gate symbol NOR Outputs 1 only if both inputs are 0 (inverse of OR). NOR operator expression NOR truth table
XOR gate symbol XOR Outputs 1 if inputs are different. XOR operator expression XOR truth table
XNOR gate symbol XNOR Outputs 1 if inputs are the same (inverse of XOR). XNOR operator expression XNOR truth table
Gate TTL Part No. # of Gates per DIP CMOS Part No. # of Gates per DIP
AND 74​08 (SN7408) 4 × 2-input AND 40​81 2 × 2-input AND
OR 74​32 (SN7432) 4 × 2-input OR 40​71 2 × 2-input OR
NOT (Inverter) 74​04 (SN7404) 6 × inverter 40​69 6 × inverter
NAND 74​00 (SN7400) 4 × 2-input NAND 40​11 2 × 2-input NAND
NOR 74​02 (SN7402) 4 × 2-input NOR 40​01 2 × 2-input NOR
XOR 74​86 (SN7486) 4 × 2-input XOR 40​30 2 × 2-input XOR
XNOR 74​266 (SN74266) 4 × 2-input XNOR 40​77 2 × 2-input XNOR

Ovation Transfer with tracking

The TRANSFER algorithm performs a transfer between the two inputs. The output is equal to the IN2 input if the digital input FLAG is TRUE, and the IN1 input if the digital input FLAG is FALSE. If the algorithm generates an invalid output value for the selected input, the other input is selected, and the algorithm generates a valid output value if the input for the other point is valid. The algorithm automatically performs a bumpless transfer between the track input and the selected input when a tracking request is removed. The algorithm ramps to the selected input (IN1 or IN2) at the specified track ramp rate (TRR1 or TRR2). Internal tracking may be selected to allow a bumpless transfer between IN1 and the IN2 inputs. Individual track ramp rates may be initialized to ramp from the IN1 to the IN2 and from the IN2 to the IN1.

Ovation PID enhancements

proportional-integral-derivative controller (or three-term controller)

Ovation UTC converter

Control logic examples




UNIX
COMMAND DESCRIPTION
uname Show the Unix system information.
uname -a Detailed Unix system information.
uname -r Kernel release information, such as kernel version.
uptime Show how long the system is running and load information.
who Display who is logged in.
w Display what users are online and what they are doing.
users List current users.
whoami Display what user you are logged in as.
su Superuser; use this before a command that requires root access (e.g. su shutdown).
cal Show calendar where the current date is highlighted.
date Show the current date and time of the machine.
halt Stop the system immediately.
shutdown Shut down the system.
reboot Restart the system.
last reboot Show reboot history.
man COMMAND Shows the manual for a given COMMAND. To exit the manual, press “q”.
Source
DOS
Files and Folders Management Commands Description
COPY Copies files to another location.
DIR Displays files and folders in the current directory.
DEL or ERASE Deletes files.
EDIT Starts the file editor.
CD Changes directory.
EXPAND Decompresses compressed files.
FC Compares files and shows the differences between them.
FIND Finds a text string in a file.
MD or MAKEDIR Creates a new folder.
MOVE Moves files from one folder to another.
PRINT Prints out the contents of a text file.
RD or RMDIR Deletes a folder.
REN or RENAME Renames a file or folder.
REPLACE Replaces files in one directory with files of the same name in another directory (overwrites).
ROBOCOPY Uses an advanced tool to copy files and directories.
TREE Displays the directory structure of a disk or folder.
TYPE Displays the contents of text files.
OPENFILES Manages opened local or network files.
XCOPY Copies files and directory trees, often used for more complex copy operations.
Applications and Processes Commands Description
SCHTASKS Executes a command or starts a scheduled application (Task Scheduler).
SHUTDOWN Shuts down or reboots your computer.
TASKLIST Lists the tasks being performed on your computer.
TASKKILL Stops or halts a task (requires the Task ID or PID, which can be found with TASKLIST).
REG Starts the registry editor.
RUNAS Launches a task as another user.
Disks Management Commands Description
CHKDISK Checks disk integrity and shows statistics.
DEFRAG Starts disk defragmentation.
CHKNTFS Displays or changes execution of disk check at boot.
COMPACT Displays and changes the compression of files in NTFS partitions.
CONVERT Converts FAT disk volume to NTFS.
DISKPART Displays and adjusts disk partition properties.
FORMAT Formats a disk or partition.
FSUTIL Displays and configures file system properties.
LABEL Creates, changes, or deletes a disk volume label.
RECOVER Recovers data from a damaged or bad disk.
VOL Displays the volume label and serial number of the disk.
System Information Commands Description
DATE Outputs or sets the current date.
TIME Displays or sets the system time.
DRIVERQUERY Displays the current state and properties of device drivers.
HOSTNAME Displays the name of the computer.
SYSTEMINFO Shows configuration information about your computer.
VER Allows you to view the Windows version.
GPRESULT Displays the currently applied group policies (RSoP).
GPUPDATE Updates group policies.
Network Management Commands Description
IPCONFIG Shows information about network interfaces and IP configuration.
PING Sends ICMP requests to the target host to check its availability.
TRACERT Finds the network path for packets traveling to a destination.
NSLOOKUP Finds the IP address for a resource name.
ROUTE Displays network route tables.
ARP Displays a table with IP addresses converted into physical (MAC) addresses.
NETSH Starts the network settings control program.
GETMAC Displays the MAC address of the network adapter.
TFTP Starts the TFTP client in the command prompt.
Command Line Setup Commands Description
CLS Clears the screen.
CMD Opens another command prompt window.
COLOR Sets the text and background color in the command prompt.
PROMPT Changes the command line prompt.
TITLE Assigns a title to the current command prompt session.
HELP Launches the CMD help interface.
EXIT Exits the command prompt.
PS
Command Description
Get-Service Retrieve information about services
Get-Process Retrieve information about processes
Get-EventLog Retrieve information from event logs
Set-ExecutionPolicy Modify the script execution policy
Test-Connection Test the connectivity to a remote computer
Out-File Write PowerShell output to a file
Get-Help Display information about concepts and commands
Get-History Retrieve recent commands in your current session
Get-Command Retrieve all available PowerShell commands
ConvertTo-HTML Create an HTML file from PowerShell output
Copy-Item Copy a file to a specific location
Clear-History Clear entries from your command history
Add-History Add entries to your command history
Format-Table Format PowerShell output as a table
Format-List Format PowerShell output as a list
Clear-Content Retain an item while deleting the contents of that item
Checkpoint-Computer Set a restore point on your machine
ForEach-Object Perform an operation on each item in a specified group
Where-Object Select objects with a certain property
Select-Object Select specific properties of an object or group of objects
Write-Progress Display a progress bar in a PowerShell window
Debug-Process Attach a debugger to a running process
Get-WinEvent Display Windows event logs
Wait-Job Suppress the command prompt until background jobs finish running
OSI
The Open System Interconnection model
Protocol Name Layer
DNS Domain Name System 7 – Application
HTTP HyperText Transfer Protocol 7 – Application
P2P Peer-to-Peer 7 – Application
POP Post Office Protocol 7 – Application
SMTP Simple Mail Transfer Protocol 7 – Application
Telnet Telnet 7 – Application
FTP File Transfer Protocol 7 – Application
HTML HyperText Markup Language 6 – Presentation
DOC Microsoft Word Document 6 – Presentation
JPEG Joint Photographic Experts Group 6 – Presentation
MP3 MPEG-1 Audio Layer III 6 – Presentation
AVI Audio Video Interleave 6 – Presentation
Sockets Network Sockets 6 – Presentation
TCP Transmission Control Protocol 5 – Session
SIP Session Initiation Protocol 5 – Session
RTP Real-Time Transport Protocol 5 – Session
RPC Remote Procedure Call (Named Pipes) 5 – Session
TCP Transmission Control Protocol 4 – Transport
UDP User Datagram Protocol 4 – Transport
SCTP Stream Control Transmission Protocol 4 – Transport
SSL Secure Sockets Layer 4 – Transport
TLS Transport Layer Security 4 – Transport
IP Internet Protocol 3 – Network
ARP Address Resolution Protocol 3 – Network
IPsec Internet Protocol Security 3 – Network
ICMP Internet Control Message Protocol 3 – Network
IGMP Internet Group Management Protocol 3 – Network
OSPF Open Shortest Path First 3 – Network
Ethernet Ethernet 2 – Data Link
802.11 IEEE 802.11 (Wi-Fi) 2 – Data Link
MAC Media Access Control 2 – Data Link
LLC Logical Link Control 2 – Data Link
VLAN Virtual LAN 2 – Data Link
ATM Asynchronous Transfer Mode 2 – Data Link
HDP High-level Data Protocol 2 – Data Link
Fibre Channel Fibre Channel 2 – Data Link
Frame Relay Frame Relay 2 – Data Link
HDLC High-level Data Link Control 2 – Data Link
PPP Point-to-Point Protocol 2 – Data Link
Q.921 ITU-T Q.921 2 – Data Link
Token Ring Token Ring 2 – Data Link
RS-232 RS-232 1 – Physical
RJ45 RJ45 Connector 1 – Physical
V.34 V.34 Modem Standard 1 – Physical
100BASE-TX 100BASE-TX Ethernet 1 – Physical
SDH Synchronous Digital Hierarchy 1 – Physical
DSL Digital Subscriber Line 1 – Physical