## Wednesday, August 22, 2018

### A/L Python in one hour - Learn by example

Variables

x=3
y="Nimal"
z=True
r=3
2x=5
_r=45
a\$5=3

Operators
= + - / *
%  //
**
5 + 3 * 2
5 + 3 * 2 / 2

#single line comment

"""
multi line
comment
"""

'''
multi
line
comment
'''

Input
name = input("Enter Your Name ")
print (name)

Data Types : number, string, boolean, list, dict
x+y
r+x

Data Type Conversion

nt=input("n tofees ")
p=input("person ")
s=p + " got " + nt + " tofees"
print(s)

x=input()
x=int(input())

nt=int(input("n tofees"))
pt=int(input("pr toffes"))
tc=nt * pt
print (tc)

nt=input("n tofees")
pt=input("pr toffes")
tc=int(nt) * int(pt)
print(tc)

nt=7
p=input("person ")
s=p + " got " + str(nt) + " tofees"
print(s)

Comparison
==
!=
===
>=
<=

IF
x=11
if x < 10:
print("low")
elif x == 10:
print ("equal")
else:
print("high")

While
x = 1
while x < 5:  # condition for loop
print (x)
x = x + 1
print ('I love python')

print ('done')

For
#0 to 9
for i in range (10):
print (i)

#range (5,10) is 5 through 9
for c in range (5,10):
print (c)

for c in range (1,6):
if c == 3:
break
print (c)

print ("out")

for letter in 'Python':
if letter == 'h':
continue
print ('Current Letter :', letter)

for i in range(4):  #to iterate between 10 to 20
for j in range(4):
print (i, j, i * j)

Functions

def greeting(name):
print ("Hello " + name)

greeting("A")
greeting("B")
greeting("C")

c=a+b
return c #  return value

print (d)
print(e)
print(f)

Formatting
# %d means integer %s is string
x = 2
y = 7
print ("-old-")
print ('The sum of %d and %d is %d' % (x, y, x + y))
print ('The sum of %d and %d is %d is %s' % (x, y, x + y, "OK"))

print ("-New-")
print ('The sum of {} and {} is {}'.format (x, y, x + y))
print ('The multi of [{}] and *{}* is {}'.format (x, y, x * y))

List
list=[1,2,3,4,5,6]

for x in list:
print (x)

list=[]
print (list)
for i in range(5):
list.append(i)

print (list)

stack= []
stack.append(1)
stack.append("Sri Lanka")
stack.append( 4)
stack.append( True)
print(stack)

print(len(stack))

a=stack.pop()
print(a)
print(stack)
stack.pop()
print(stack)

Array & List
Array=(3,2,1)
List=[3,2,1]

print(List, Array)
print(Array[0],List[0])

List[2]=4
print(List)

# Array[2]=4 # error

dict = {'Name': 'Ganesh', 'Age': 17, 'Class': 12}
print(dict)
print (dict['Name'])
print (dict['Age'])

dict['Age'] = 18
dict['Class'] = 13
dict['School'] = "RRCK"

print(dict)

Files
f = open("myfile.txt", "w") #write only
f.write( "Python is cool\n")
f.write( "iPython is very cool")
f.close() #Close file

f = open("myfile.txt", "r")
print(s)
f.close()

input()

f = open("myfile.txt", "r")
print(line)
f.close()

input()

f = open("myfile.txt", "r")
print(lines)
f.close()

L=[0,1,2,3,4,5,6]
print(L)
print("L[0]" , L[0])
print("L[2:]", L[2:])
print("L[:3]", L[:3])
print("L[2:3]", L[2:3])
print("L[:]", L[:])
print("L[:0]",L[:-1])
print("L[:-2]", L[:-2])

1. Study and Run Codes
2. Explore what happens - do some tinkering
3. Draw Flow Charts

Solve this problem

1. Once upon a time, there were three little crows - ages 2, 4, and 6. What is the total of their ages?

1. Each little Crow wanted to build a house. Crow #1 wanted to build a house of straw. Straw costs Rs.4 a bundle. He needs 9 bundles. How much will he spend?
2. Once upon a time, there were three little crows. They were Lady Crow, Lord Crow, and Sister Crow. Lady Crow was 5 years old. Lord Crow was 4 years old and Sister Crow was 3 years old. What was their total age?
4. Master Crow bought 4 milk toffees at 3 Rupees. Next he bought 3 chocs, each cost 10 Rupees. How much balance he would get when he give 100 Rupee note.

5. Your Grandpa likes you talking with him. If you type in normal case, he responds with "HUH?! SPEAK LOUD KID!" . If you type in capital, he responds with "NO, NOT SINCE 1945!". Every time he responds he forget the year and tell a random year between 1945 to 1960.

When you say "BYE" he says "STAY!". But when you say "BYE" 3 times you can leave.

## Friday, May 18, 2018

### How to prevent a ransomware attack!

How does a ransomware infection occur?

• Email messages that carry downloader trojans, which attempt to install ransomware
• Websites hosting exploit kits that attempt use vulnerabilities in web browsers and other software to install ransomware

More recent ransomware have worm-like capabilities that enable them to spread to other computers in the network. For instance, Spora drops ransomware copies in network shares.
1. Keep clear inventories of all of your digital assets and their locations, so cyber criminals do not attack a system you are unaware of.
2. Keep all software up to date, including operating systems and applications.
3. Back up all information every day, including information on employee devices, so you can restore encrypted data if attacked.
4. Back up all information to a secure, offsite location.
5. Segment your network: Don't place all data on one file share accessed by everyone in the company.
6. Train staff on cyber security practices, emphasizing not opening attachments or links from unknown sources.
7. Develop a communication strategy to inform employees if a virus reaches the company network.
8. Before an attack happens, work with your board to determine if your company will plan to pay a ransom or launch an investigation.
9. Perform a threat analysis in communication with vendors to go over the cyber security throughout the lifecycle of a particular device or application.
10. Instruct information security teams to perform penetration testing to find any vulnerabilities.

## Friday, March 2, 2018

### Patterns are heart of algorithmic programming. Code 100 problems in python.

Patterns are heart of programming algorithms. They are not difficult program. All you have to do is study relationships and occurrences. Write a programs to produce given outputs using python.

```Q.1    structure:
\$\$\$\$\$
\$\$\$\$\$
\$\$\$\$\$
\$\$\$\$\$
\$\$\$\$\$

Q.2    #'s triangle:
# # # # #
# # # #
# # #
# #
#

Q.3    \$'s triangle:
\$ \$ \$ \$ \$
\$ \$ \$ \$
\$ \$ \$
\$ \$
\$

Q.4    #'s triangle:-
#
##
###
####
#####

Q.5    \$'s triangle:

\$
\$ \$
\$ \$ \$
\$ \$ \$ \$
\$ \$ \$ \$ \$

Q.6    numbers structure:
12345
12345
12345
12345
12345

Q.7    numbers structure:
54321
54321
54321
54321
54321

Q.8    numbers structure:
55555
44444
33333
22222
11111

Q.9    numbers structure:
11111
22222
33333
44444
55555

Q.10    numbers structure:
1
12
123
1234
12345

Q.11    numbers structure:
12345
1234
123
12
1

Q.12    numbers structure:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Q.13    numbers structure:
54321
4321
321
21
1

Q.14    numbers structure:
1
21
321
4321
54321

Q.15    numbers structure:
12345
1234
123
12
1

Q.16    numbers structure:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Q.17    numbers structure:
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1

Q.18    numbers structure:
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1

Q.19    triangle
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * * * * * *

Q.20  Floyd's triangle:
1
2 3
4 5 6
7 8 9 10

Q.21  Pascal triangle:
1
1 1
1 2 1
1 3 3 1

Q.22  character triangle:
A
B B
C C C
D D D D

Q.23   character triangle:
A
A B A
A B C B A
A B C D C B A
A B C D E D C B A

Q.24   character triangle:
A B C D E D C B A
B C D E D C B
C D E D C
D E D
E

Q.25  number structure:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

Q.26 :

S
SR
SRI
SRIL
SRILA
SRILAN
SRILANK
SRILANKA

Q.27  character structure:
A
BB
CCC
DDDD
CCC
BB
A

Q.28  number triangle:

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Q. 29  number structure:

123454321
2345432
34543
454
5

Q.30.  number triangle structure:-

1
21
321
4321
54321

Q.31.  number triangle structure:

54321
4321
321
21
1

Q.32    number pyramid:

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6

Q.33    number structure:

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6

Q. 34  rhombus symbol structure:

*
***
*****
*******
*****
***
*

Q. 35  number rhombus structure:

1
212
32123
4321234
32123
212
1

Q. 36 number rhombus structure:

1
121
12321
1234321
12321
121
1

Q.37  character rhombus structure:

A
ABA
ABCBA
ABCDCBA
ABCBA
ABA
A

Q.38  square character triangle:

A
ABA
ABCBA
ABCDCBA

Q.39  square character triangle:

ABCDCBA
ABCBA
ABA
A

Q.40  square character triangle:

A
AB
ABC
ABCD
ABCDE
ABCD
ABC
AB
A

Q.41  square character triangle:

A
BA
CBA
DCBA
EDCBA
DCBA
CBA
BA
A

Q.42    character triangle:

EDCBA
DCBA
CBA
BA
A

Q.43    number design/triangle:

9
0 1
2 3 4
5 6 7 8
9 0 1 2 3

Q. 44    number rectangle:

12344321
123__321
12____21
1______1

Q. 45    number pyramid or number structure:

1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9

Q. 46 number pyramid:

123456654321
1234554321
12344321
123321
1221
11

Q. 47 character pyramid:

ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABBA
AA

Q. 48    number pyramid:

1
222
33333
4444444
555555555

Q. 49   number triangle:

9
898
78987
6789876

Q. 50   number triangle:

5
45
345
2345
12345

Q. 51   number triangle:

5
454
34543
2345432
123454321

Q. 52   star structure/fashion:

*********
*******
*****
***
*
***
*****
*******
*********

Q. 53    rectangle number pyramid:

33333
32223
32123
32223
33333

Q. 54  the star triangle frame pyramid like :

*
**
* *
*  *
*   *
*    *
*     *
*      *
*       *
**********

Q. 55    star pattern pyramid:

*
***
******

Q. 56  reverse star pyramid :

**********
****  ****
***    ***
**      **
*        *

Q. 57  odd number series pyramid :

1
3  5  7
9 11 13 15 17 19

Q.58   number pyramid/triangle:

54321
5432
543
54
5

Q.59  the number character pyramid :

1
AB
123
ABCD
12345

Q. 60   Floyd triangle :

1
2 3
4 5 6
7 8 9 10

Q.61   number pyramid:

1 2 3 4 5
2 3 4 5
3 4 5
4 5
5

Q.62   character pyramid:

A
BA
ABA
BABA
ABABA

Q.63 rows input pyramid :

*
**
***
****
***
**
*

Q.64   number pyramid:

1
232
34543
4567654

Q.65   number rectangle structure:

12321
12 21
1   1
12 21
12321

Q.66   character rectangle design:

ABCBA
AB BA
A   A
AB BA
ABCBA

Q.67   star triangle structure:

*********
*******
*****
***
*

Q.68   number rectangle program:

1234
2341
3412
4123

Q.69   character rectangle program:

ABCD
BCDA
CDAB
DABC

Q.70   number pyramid program:

1234
341
12
3

Q.71   character pyramid program:

ABCD
CDA
AB
C

Q.72   number pyramid using function:

1
2 3
4 5 6
7 8 9 1
2 3 4 5 6

Q.73   number pyramid:

1
123
12345
1234567

Q.74   number pyramid:

1333
2222
3331

Q.75  number character pyramid :

1      a
21     ba
321    cba
4321   dcba
54321  edcba

Q.76  0 and 1 number triangle :

1
01
010
1010
10101

Q.77 1 and 0 pyramid :

1
01
101
0101
10101

Q.78 Square star pyramid :

*****
*     *
*     *
*****

Q.79 Rectangle star pyramid :

******
*    *
*    *
******

Q.80 Even-odd number star pyramid :

1
*2
1*3
*2*4
1*3*5

Q.81  character number pyramid :

1
A B
2 3 4
C D E F
5 6 7 8 9

Q.82 nested star pyramid :

* *** *** *
** ** ** **
*** * * ***

Q.83 random number pyramid :

4572
572
72
2

Q.84 number design:

1
23
4
56
7
89
10

Q.85 number pyramid:

1
121
1231
12341
123451

Q.86 continues number pyramid:

1
121
12321
1234321
123454321

Q.87 alternative number-star pyramid :

1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1

Q.88 diagonal star-zero pyramid :

*000000
0*00000
00*0000
000*000
0000*00
00000*0
000000*

Q.89 geometric sequence pyramid :

7
14 15
28 29 30 31
56 57 58 59 60 61 62 63

Q.90 nested pyramid :

#####*#####
####*#*####
###*###*###
##*#####*##
#*#######*#
*#########*

Q.91 half-square number triangle :

543212345
4321234
32123
212
1

Q.92 equilateral triangle number :

5
454
34543
2345432
123454321

Q.93 positive-negative number triangle :

9
8  6
7  5  3
4  2  0 -2
1 -1 -3 -5 -7

Q.94 Star-Zero nested pattern:

*000*000*
0*00*00*0
00*0*0*00
000***000

Q.95 continuous vertical number pyramid:

1
2  7
3  8 13
4  9 14 19
5 10 15 20 25

Q.96 Nested number character pyramid:

A
1
BB
22
CCC
333

Q.97 two symbol pyramid:

\$
#
\$\$
##
\$\$\$
###

Q.98 Square number pyramid :

1
1 4 9
1 4 9 16 25
1 4 9 16 25 36 49
1 4 9 16 25 36 49 64 81

1234
12345
123456
1234567
123456
12345
1234

Q.100 The hexagon pattern

____        ____        ____
/    \      /    \      /    \
/      \____/      \____/      \
\      /    \      /    \      /
\____/      \____/      \____/
/    \      /    \      /    \
/      \____/      \____/      \
\      /    \      /    \      /
\____/      \____/      \____/
/    \      /    \      /    \
/      \____/      \____/      \
\      /    \      /    \      /
\____/      \____/      \____/

```
Source : cprogrammingcodes.blogspot.com

## Friday, February 16, 2018

### micro:bit ශූරතාවලිය - අවසාන ප්‍රතිඵල

මයික්‍රෝබිට් මිතුරනි,
ශ්‍රී ලංකා ජාතික ගීය, මයික්‍රෝ මරියෝ, ෆ්ලැපි කුරුල්ලා, පොර පොල්, මයික්‍රෝ නැටුම වැනි අගනා micro:bit නිර්මාණ 400 කට වඩා ඉදිරිපත්වූ පළමු micro:bit ශූරතාවලිය අනාගත බලාපොරොත්තු රැසක් සමග සාර්ථකව සිදුඋනා. අප ලද වඩාත් අගනා ප්‍රතිඵලය IoT හා robotics සඳහා පරිගණක විද්‍යාව, කේතනය හා ඇලොගරිතම ඉගනීමට දැනුම සම්භාරයක් ප්‍රජාව මුල්කරගන http://microbit.info.lk හි නිර්මාණය වීමයි. දැන් ICT සිසුනට හා ගුරුවරුන්ට ඒවා භාවිතා කර micro:bit කේතනය ඉගනීමට හැකි වේවි. ලොව පුරා සිසුන්, ගුරුවරුන් හා තාක්‍ෂණඥයින්ගේ micro:bit ප්‍රජාවක්ද microbit club වටා ගොඩනැගීමද, ඔවුනොවුන් හඳුනා ගැනීමටද අපට සැමට අවස්ථාව ලැබුණා. අප දැන් 1300 කට වඩා සමූහයක්. ශූරතාවය තුලින්
අප සැම ගොඩක් දේ ඉගෙන ගත්තා. එයට ඔබ සැමට ස්තූතියි.

micro:bit ශූරතාවලියේ ප්‍රතිඵල!
14 න් පහළ micro:bit ශූරයා චමිත් ඉඳුවර (නිර්මාණ 21, මනාප 457)
19 න් පහළ micro:bit ශූරයා හිමාෂ් තිලකරත්න (නිර්මාණ 21 මනාප 250)
විශ්ව විද්‍යාල micro:bit ශූරයා කසුන් දිසානායක (නිර්මාණ 23 මනාප 612)
ගුරුවරුන්ගේ micro:bit ශූරයා උමාර රත්නායක (නිර්මාණ 5 මනාප 65)
විවෘත micro:bit ශූරයා ඉවාන් බොස්නික් (නිර්මාණ 27 මනාප 117)
විශේෂ සඳහන් කිරීම්!
14 න් පහළ - සිතුම් දුලේන් ප්‍රනාන්දු, හබීබා ඈන්ස්, අසීම් ෆයිසාල්, ඉනුකි වික්‍රමතිලක
19 න් පහල - හන්සල සෙනවිරත්න, නදූෂන් , ටී මුරලි
විශ්ව විද්‍යාල - ක්‍රිස්ටීන් ප්‍රනාන්දු
ගුරුවරු - ජිනානි වලිසුන්දර
විවෘත - ඇලෙක්ස් ෆ්ලෝරිජාන්, සිමුන් බිලාස්, නිකෝලා පෙට්රොවික්, එන් වීරකුමාර , විශ්ව කුමාර
micro:bit ශූරතාවලියේ ජයග්‍රාහකයන්ටත්, සහභාගී වූ සැමටත්, එය නැරඹා නිර්මාණ අගය කල ඔබ සැමටත් microbit club, shilpa64 හා algohack ප්‍රණාමය.
ඊළඟට micro:bit ලෝක ශූරතාවලය ගණිතය ගැන.
විස්තර ලගඳීම. නැවතත් ස්තූතියි. මෙය Share කරන්න.
micro:bit තාක්‍ෂණ අධ්‍යාපනයට වැදගත්ම උපකරණයක්.
විස්තර සඳහා බලන්න. http://microbit.info.lk
සංවිධානය හා තාක්‍ෂණය
Sagara Ekanayake (Silicon Hills)
Niranjan Meegammana (Shilpa Sayura Foundation)
NP Vishva Kumara (info.lk)
Yamuna Rathnayake (RRCK)
තවත් විස්තර!
ශූරතාවලිය :https://goo.gl/VRARSD
තරඟ ප්‍රශ්ණ : https://goo.gl/upKGUf
තරඟ නිර්මාණ http://microbit.info.lk
මයික්‍රෝබිට් පාඩම් : https://goo.gl/31qKry
සංවිධානය : http://shilpasayura.org සහ ප්‍රජාව
අනුග්‍රහය හා මයික්‍රෝබිට් ලබාදීම http://microbitclub.info.lk

## Thursday, February 15, 2018

### Model View Controller (MVC) Pattern with Java Script

The Controller (C) listens to event stream.  Here we use click event

View (V) knows how to render data from the Model.

The Controller tells to View to do something with Model data.
The View knows nothing about the Model apart from it's interface
The Model knows nothing of the View and the Controller
The Controller knows about both the Model and the View
The Controller tells the View to do something with the data from the Model

You need to add form input elements and a button to experiment this code.

```var M = {}, V = {}, C = {};

/* Controller Handles the Events */
/* Model Handles the Data */
/* View Handles the Display */

M = {
data: {
userID : "440"
},
setData : function(d){
this.data.userID = d.userID;
},
getData : function(){
return data;
}
}

V = {
userID : document.querySelector("#inputUserID"),
update: function(M){
this.userID.value = M.data.userID;
}
}

//Controller handles all
C = {
model: M,
view: V,
handler: function(){
this.view.update(this.model);
}
}

//event
C.handler.call(C);
});

```

## Wednesday, February 14, 2018

### PHP MySQLi object oriented implementation

MySQLi - i standing for 'improved'.

PDO
PDO works with various different database systems
MySQLi will only work with MySQL databases.
Both are object oriented, but MySQLi allows procedural usage also.

PHP MySQLi object oriented implementation,

Connecting
Create a new instance of MySQLi on localhost database

\$db = new mysqli('localhost', 'mysql_database', 'pass', 'demo');

if(\$db->connect_errno > 0){
die('Unable to connect to database [' . \$db->connect_error . ']');
}

Querying

\$sql = SELECT * FROM `users` WHERE `live` = 1
\$result = \$db->query(\$sql)

if(!\$result ){
die('There was an error running the query [' . \$db->error . ']');
}

Output query results
To loop through the results and output the username

while(\$row = \$result->fetch_assoc()){
}

Number of returned rows

<?php
echo 'Total results: ' . \$result->num_rows;
?>

Number of affected rows

<?php
echo 'Total rows updated: ' . \$db->affected_rows;
?>

Free result set
It's advisable to free a result after use

\$result->free();

This will free up some system resources, and is a good practice to get in the habit of doing.

Escaping characters

\$db->real_escape_string('This is an unescaped "string"');

\$db->escape_string('This is an unescape "string"');
The string should now be safer to insert into your database through a query.

close the connection:

\$db->close();

Define a statement

\$statment = \$db->prepare("SELECT `name` FROM `users` WHERE `username` = ?");

Bind parameters
\$name = 'Bob';
\$statement->bind_param('s', \$name);
Execute the statement
\$statement->execute();

Iterating over results

\$statement->bind_result(\$returned_name);

while(\$statement->fetch()){
echo \$returned_name . '<br />';
}

Close statement

\$statement->free_result();

MySQLi Transactions

Disable auto commit
You need to make it so that any query you submit doesn't automatically commit in the database.

\$db->autocommit(FALSE);

Commit the queries
After a few queries that you've ran using \$db->query()
we can call a simple function to commit the transaction:

\$db->commit();

Rollback
roll something back:

\$db->rollback();

• Subnets:
• Hosts:
• Class:
Decimal Binary
Network ID
Subnet ID
First Host
Last Host

## Saturday, February 3, 2018

### What is a proxy Server ?

proxy server is a server that acts as an intermediary for requests from clients
and seeks resources from other servers

A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource available from a different server and the proxy server evaluates the request as a way to simplify and control its complexity.

HTTP Proxy – The HTTP proxy works with web browsers (HTTP clients) and servers that support HTTP. The HTTP proxy caches pages, or store them, for faster retrieval and are used occasionally to increase metadata services available on the website.

Gateway Proxy – A proxy that allows requests and information to travel through without modification is called a gateway, or gateway proxy. T

Content Filter – The filter that might be blocking the sites you wish to access is likely a form of a proxy as well. These specialized proxies called content filters require all requests to pass through for review. The content filter proxy then blocks requests that match requests on a "black list" or based on certain security settings. Depending on the complexity of the content filter, network administrators can add to or remove items from the black list.

DNS Proxy - A DNS proxy server takes DNS queries from a ( Usually local ) networks and forwards them to an Internet Domain Name Server. It may also cache DNS records.

Anonymous HTTPS proxy - Users wanting to bypass web filtering, that want to prevent anyone from monitoring what they are doing, will typically search the internet for an open and anonymous HTTPS transparent proxy. T

Use of HTTPS proxies are detectable even without examining the encrypted data, based simply on firewall monitoring of addresses for frequency of use and bandwidth usage.

TOR Proxy - Tor ( The Onion Router) is a system intended to enable online anonymity. Tor client software routes Internet traffic through a worldwide volunteer network of servers in order to conceal a user's location or usage from someone conducting network surveillance or traffic analysis. Using Tor makes it more difficult to trace Internet activity, including "visits to Web sites, online posts,

I2P anonymous proxy - The I2P anonymous network ( I2P ) is a proxy network aiming at online anonymity. It implements garlic routing, which is an enhancement of Tor's onion routing. I2P is fully distributed and works by encrypting all communications in various layers and relaying them through a network of routers run by volunteers in various locations. By keeping the source of the information hidden, I2P offers censorship resistance. The goals of I2P are to protect users' personal freedom, privacy, and ability to conduct confidential business.

Each user of I2P runs an I2P router on their computer (node). The I2P router takes care of finding other peers and building anonymizing tunnels through them. I2P provides proxies for all protocols (HTTP, IRC, SOCKS, ...).
USES OF PROXIES
1. Filtering of encrypted data
2. Bypassing filters and censorship
3. Logging and eavesdropping
4. Improving performance
5. Security
6. Cross-domain resources
7. Translation
8. Anonymousity

# It is the  standard security technology today.It establishes an encrypted linkBetween a web server and a browser.HTTP and HTTPS HTTP link is not encrypted HTPS is encrypted and secure communication.How HTTP and HTTPS work?A (client) and B (server) are two devices. A sends password to BB receive password.hacker access in between.

In HTTPS
SSL communication used to encript messages.
A sends message on the network.
B receive themessage on the network.
Now hacker see password as “xYhVIO9l”
How SSL works?
A SSL Certificate issued to a websites by a certifying agency. A security certificate installed in web server with SSL capability..

SSL system consists of a Public key and a Private key. Public key is used to encrypt the information
Private key is used to decrypt it.

## Monday, January 29, 2018

### Issues of IoT

• Cyber security
• Privacy
• Software licensing
• Data use and ownership
• Regulation

IoT cyber security is a moving target. When a patch or fix is developed, it’s only a matter of time
before hackers find ways around it. In situations where IoT security is breached, who is liable? Is the
software maker liable if it doesn’t update its software? Who is liable if the software maker updates its software, but the user doesn’t
download the update? What happens if the software maker updates the software, but the user doesn’t know there’s an update?

Privacy and Laws
Privacy laws vary across countries. The Europeans are very protective
of privacy, and the US is less protective. Video rental habits are protected by federal laws,
not clear to of data generated by an implantable cardiac monitor is protected. Who owns datathat describes the quality and quantity of your heartbeats.

Governing the Internet of Things

Software Licensing—It’s Complicated
IoT requires software and hardware from multiple vendors.
Maintaining the software, hardware stack can be expensive.
In the IoT economy, there will be a handful of end-to-end solutions and a broad assortment of mash-ups.

Data Use and Ownership—Who Controls What?
who owns what data, where can it be sent, who is allowed to use it and how much if
it can be stored across the IoT landscape.

As the IoT becomes a more dominant force in our lives, the data it generates will become more valuable. Since the laws governing data ownership are ambiguous, rights associated with ownership are so unclear, look at who controls the use of data. It should be the consumer

Autonomous driving raises questions about data ownership and usage.
If a driverless car is involved in an accident, who is liable and who is allowed to review data relating to the accident? Will the manufacturer of the car want to see the data so it can lodge a suit against the developer who wrote the navigational software? Will network providers be required to share data with law enforcement agencies when autonomous vehicles collide?
Many questions but few answers yet .

Government regulation—or the lack of it
In the driverless car, precisely who is responsible in case of an accident—the owner of the car,
the company that made the car, or the company that wrote the software
guiding the car?

## Wednesday, January 24, 2018

### Subnetting in 5 minutes

192.168.1.7 is an IP in IPV4 standard
IPV4 networks have 32bits.
Each 8bit is a Network ID.
Each Network ID represent number between 0-255

There are 4 basic classes A , B C, D
The first ID or 8 bits is network class
0-127 - Class A
128 - 191 Class B
192 -  223 Class C
223 + Class D & E kept for research purpose

Class First Network ID Last Network ID
Class A 1.0.0.0 126.0.0.0
Class B 128.0.0.0 191.255.0.0
Class C 192.0.0.0 223.255.255.0

If we have a class C network
The first 3 numbers are network ID  192.168.1
The last number is host ID
First host id (0) is network id and last (255 broadcast id) not used
So in the network we have host ids from
192.168.1.1 - 192.168.1.254 we can have 254 hosts (computers or devices)
We do sub netting to separate network traffic , like partitioning  house.
we can make 2 networks each having 254/2 - 1*2  hosts
or make 4 networks having  254/4 - 1 *4

Every time we break the network the first and last host IDs are used as subnets network ID and broadcast ID.

So they cant be used  as host IDs..
A disadvantage of subnetting is reducing of usable IPs in a network.

In order to tell the network how many computers we have in the subnet we use a subnet mask. Another number which tells how many subnet networks have been created.
When we have 254 computers in a class C network we use
255.255.255.0 as subnet mask so 192.168.1.1- 192.168.1.255 ips available to us.
When we break the network into two subnets. We have to put a boundry between them by changing the subnet mask.

Here subnet mask borrow one bit from host ID
The IP range of sub network A now is 192.168.1.1- 192.168.1.126
The IP range of sub network B now is 192.168.1.129- 192.168.1.253
The first and last IP of each subnet used for subnetworkid and broadcast address.

Check here
http://www.subnet-calculator.com/

In detail http://ict.shilpa64.lk

## Sunday, January 21, 2018

### උසස් පෙළ ICT ආදර්ශ ප්‍රශ්න පත්‍රය

අපොස උසස්පෙළ සඳහා ගුරුවරුන් රැසක් සම්පාදනය කළ ආදර්ශ ප්‍රශ්න. උත්සාහ කර බලන්න.