CL-CY LEVEL 2 REPORT
31 / 3 / 2024
Task 1 - Javascript
let us understand some basic concepts of javascript
1. Variables-these are containers for storing data values can be declared using \var\"
\"let\" \"const\" commands
2. Data types - javascript has several data types which include numbers, strings, booleans, arrays, objects, and more.
declaration:
var num = 10;
var str = \"JavaScript\";
var bool = true;
var arr = [1, 2, 3];
var obj = { name: \"sai\", age: 19 };
3. Operators - java script supports most of the operators which include arithmetic, assignment, comparison, logical, and more.
4. Functions- functions are more like building blocks of the code , they are blocks of reusable code which will return a particular value or task for which it is used
command: \"function\"
5. Conditional Statements: JavaScript supports if-else and switch statements for conditional execution of code. these include ,=
6. Loops: JavaScript provides for loops, while loops, and do-while loops for iteration.
example:
for (var i = 0; i < 5; i++) {
console.log(\"Iteration \" + i);
}
7. Arrays: Arrays are used to store multiple values in a single variable.
example:
var fruits = [\"Apple\", \"Banana\", \"Orange\"];
console.log(fruits[0]);
8. Objects: Objects are collections of key-value pairs.
example:
var person = {
name: \"John\"
age: 3 n city: \"New York\"
};
console.log(person.name);
9. DOM Manipulation: JavaScript can be used to manipulate HTML elements and change their content, attributes, or styles.
example:
document.getElementById(\"demo\").innerHTML = \"Hello, World!\";
10. Events: JavaScript can respond to user actions like clicks, mouse movements, key presses, etc., through event handling.
example:
document.getElementById(\"myButton\").addEventListener(\"click\", function() {
console.log(\"Button clicked!\");
});
my code is attaches to github: https://github.com/sai282828/MARVEL-LEVEL-2-TASKS.git
"
Task 2 - Async javascript
so in this task we have to use a small callback based program that displays steps for a food recipe , using asynchronous javascript
Now what do we understand by async js ,this type of programming is used where we need async code meaning to allow certain operations to be executed independently of the main program flow
Here are some features of async javascript
-Callbacks: Callbacks are functions passed as arguments to other functions, to be executed later once a specific operation has completed. Callbacks are a foundational concept in asynchronous JavaScript programming.
-Promises: Promises are objects representing the eventual completion or failure of an asynchronous operation. They provide a cleaner alternative to callbacks, enabling better error handling and sequential composition of asynchronous tasks.
The above is the image of the code
Task 3 - Promises
Now for the same task done above we need to use promises
let us understand what a promises are in js:
Promises in JavaScript are objects representing the eventual completion or failure of an asynchronous operation. They provide a better alternative to traditional callback-based approaches for handling asynchronous code. Promises have three states: pending, fulfilled, or rejected. Once a promise is fulfilled or rejected, it is considered settled, and its associated handlers are called accordingly.
how are promises better than callback based program
-Improved readability
-Better error handling
-Avoidance of call back hell
-composition and transformation
The image for the code will be provided below
Task 4 - VI
In this task we have to learn some basic concepts of vi and its uses , now we all may have a doubt what is vi . vi is a powerful text editor , its a modal editor meaning it operates in different modes for editing , navigation and command execution and mostly used in unix based systems.
now lets see some of vi commands using markdown
The above pic contains most of the commands of vi
Github:https://github.com/sai282828/MARVEL-LEVEL-2-TASKS.git
Task 5 - Get Familiar with linux basics
In this task we have to learn linux and its basic commands to create a directory with 2600 files and using the cat command we need to concatenate two files containing information
commands used
-mk dir
-touch
-cat
these above commands are basics of linux and the pictures are attached below:
so these are the basics i leanrt about linux .
Task 6 - Cyber security
Here we have to learn various ciphers and be able to decode them let us understand all the ciphers involved
-Caesar Cipher: A substitution cipher where each letter in the plaintext is shifted a certain number of places down or up the alphabet, with a fixed shift amount.
-Pigpen Cipher: A geometric substitution cipher where letters of the alphabet are represented by a set of symbols arranged in a grid of lines and dots, often used for simple encryption or secret writing.
-Morse Code: A method of encoding text characters as sequences of dots and dashes or short and long signals, used for communication over long distances, especially in telegraphy and radio transmission.
-Rail Fence Cipher: A transposition cipher that writes the plaintext in a zigzag pattern across multiple "rails" and then reads off the ciphertext, useful for simple encryption with basic pattern rearrangement.
-Polybius Cipher: A substitution cipher where each letter is replaced by its coordinates in a grid, typically a 5x5 grid, enabling simple encryption with numerical representation.
-Playfair Cipher: A digraph substitution cipher that encrypts pairs of letters in the plaintext based on a keyword and a 5x5 grid, commonly used for more secure encryption with enhanced letter transposition.
Now let us convert following text "hi i am sai" into the above ciphers
-Caesar Cipher (Shift 3):
Shift 3: "kl l dp vdl"
-Morse Code:
".... .. / .. / .- -- / ... .- .."
-Rail Fence Cipher:
"hiaiiam"
-Polybius Cipher:
"32 24 23 22 11 12 34"
-Playfair Cipher:
"DL BK AP RI"
-pigpen cipher: so these are the various ciphers involved in cybersecurity
Task 7 - Linux contnued
In this task we need learn basics of regex and pipex and from the above two we need to also learn how grep works here are some basics
-Basics of Regex: Regex, short for regular expressions, is a sequence of characters that define a search pattern. It's a powerful tool for pattern matching and finding strings within text.
-Piping in Linux: Piping (|) is a way to redirect the output of one command as input to another command. This allows you to chain commands together, performing complex operations by combining the functionalities of different commands.
-Understanding grep: grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. It's commonly used to filter output, search files, and perform pattern matching.
from the basics of regex and pipex i have extracted login login times within a date/time range from the login logs using the 'last' command. Pipe this information into a text file and put it into a folder named logs. Zip this folder using gzip and tar.