Recently I got a requirement in a project to convert own type of object to DataTable. Here I am sharing my code with you.
Steps
1. Create datatable and give a name
2. Create Column Names
3. Create a Data Row
4. Add Data in to DataRow
5. Add DataRow to DataTable
Thats it...
Here some Extended Method to how to use this method
https://github.com/cbjpdev/DataTableX
Wednesday, March 6, 2013
Saturday, September 29, 2012
Unicast example in Contiki
Simple unicast example, Click button in each node to unicast message.
Please consider that this code is written for cooja simulator.
Please consider that this code is written for cooja simulator.
UniA.c for node 1
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
PROCESS(example_unicast_process, "Example unicast");
AUTOSTART_PROCESSES(&example_unicast_process);
static void
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{
printf("broadcast message received from %d.%d: '%s'\n",from->u8[0], from->u8[1], (char *)packetbuf_dataptr());
}
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
static struct unicast_conn uc;
static void unicast_message()
{
unicast_open(&uc, 146, &unicast_callbacks);
rimeaddr_t addr;
packetbuf_copyfrom("AAAAA", 5);
addr.u8[0] = 2;
addr.u8[1] = 0;
if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr))
{
unicast_send(&uc, &addr);
}
}
PROCESS_THREAD(example_unicast_process, ev, data)
{
PROCESS_EXITHANDLER(unicast_close(&uc);)
PROCESS_BEGIN();
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
unicast_message();
printf("message sent.\n");
}
PROCESS_END();
}
UniB.c for node2
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
PROCESS(example_unicast_process, "Example unicast");
AUTOSTART_PROCESSES(&example_unicast_process);
static void
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{
printf("broadcast message received from %d.%d: '%s'\n",from->u8[0], from->u8[1], (char *)packetbuf_dataptr());
}
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
static struct unicast_conn uc;
static void unicast_message()
{
unicast_open(&uc, 146, &unicast_callbacks);
rimeaddr_t addr;
packetbuf_copyfrom("BBBBB", 5);
addr.u8[0] = 1;
addr.u8[1] = 0;
if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr))
{
unicast_send(&uc, &addr);
}
}
PROCESS_THREAD(example_unicast_process, ev, data)
{
PROCESS_EXITHANDLER(unicast_close(&uc);)
PROCESS_BEGIN();
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
unicast_message();
printf("message sent.\n");
}
PROCESS_END();
}
Friday, September 14, 2012
Prime Fields Example
In cryptography, prime fields play major role in its mathematical problems. Below you can see a simple example of a prime field 29 which denoted by F29.
The elements of F29 are {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27 28}
For any integer a, a mod p shall denote the unique integer remainder r , 0 ≤ r ≤ p − 1, obtained upon dividing a by p; this operation is called reduction modulo p.
(i) Addition: 17 + 20 = 8 since 37 mod 29 = 8
(ii) Subtraction: 17 − 20 = 26 since −3 mod 29 = 26
(iii) Multiplication: 17 · 20 = 21 since 340 mod 29 = 21
(iv) Inversion: 17−1 = 12 since 17 · 12 mod 29 = 1
Monday, September 10, 2012
RSA Encryption Scheme
RSA, named after its inventors Rivest, Shamir and Adleman, was proposed in 1977 shortly after the discovery of public-key cryptography.
RSA key pair generation
INPUT: Security parameter l.
OUTPUT: RSA public key (n, e) and private key d.
1. Randomly select two primes p and q of the same bitlength l/2.
2. Compute n = pq and φ = ( p − 1)(q − 1).
3. Select an arbitrary integer e with 1 < e < φ and gcd(e, φ) = 1.
4. Compute the integer d satisfying 1 < d < φ and ed ≡ 1 (mod φ).
5. Return(n, e, d)
Basic RSA encryption
INPUT: RSA public key (n, e), plaintext m ∈ [0, n − 1].
OUTPUT: Ciphertext c.
1. Compute c = me mod n.
2. Return(c)
Basic RSA decryption
INPUT: RSA public key (n, e), RSA private key d, ciphertext c.
OUTPUT: Plaintext m.
1. Compute m = cd mod n.
Sunday, September 9, 2012
RSA Digital Signature Scheme
RSA, named after its inventors Rivest, Shamir and Adleman, was proposed in 1977 shortly after the discovery of public-key cryptography.
RSA key pair generation
INPUT: Security parameter l.
OUTPUT: RSA public key (n, e) and private key d.
1. Randomly select two primes p and q of the same bitlength l/2.
2. Compute n = pq and φ = ( p − 1)(q − 1).
3. Select an arbitrary integer e with 1 < e < φ and gcd(e, φ) = 1.
4. Compute the integer d satisfying 1 < d < φ and ed ≡ 1 (mod φ).
5. Return(n, e, d).
Basic RSA signature generation
INPUT: RSA public key (n, e), RSA private key d, message m.
OUTPUT: Signature s.
1. Compute h = H (m) where H is a hash function.
2. Compute s = hd mod n.
3. Return(s).
Basic RSA signature verification
INPUT: RSA public key (n, e), message m, signature s.
OUTPUT: Acceptance or rejection of the signature.
1. Compute h = H (m).
2. Compute h` = se mod n.
3. If h = h` then return(“Accept the signature”);
Else return(“Reject the signature”).
Wednesday, August 29, 2012
Solution for New XAMPP security concept in ubuntu
When you are using phpmyadmin in XAMPP 1.8.0, you will be faceed this problem. To avoid this you will need to do some changes in httpd-xampp.conf file.
Open file as super user
sudo gedit /opt/lampp/etc/extra/httpd-xampp.conf
It will looks like this
2. Change according to red colored changes
Then restart the XAMPP again.
If you consider about security, do not use this method
Open file as super user
sudo gedit /opt/lampp/etc/extra/httpd-xampp.conf
It will looks like this
1: <IfDefine PHP4>
2: LoadModule php4_module modules/libphp4.so
3: </IfDefine>
4: <IfDefine PHP5>
5: LoadModule php5_module modules/libphp5.so
6: </IfDefine>
7: # Disabled in XAMPP 1.8.0-beta2 because of current incompatibilities with Apache 2.4
8: # LoadModule perl_module modules/mod_perl.so
9: Alias /phpmyadmin "/opt/lampp/phpmyadmin"
10: Alias /phpsqliteadmin "/opt/lampp/phpsqliteadmin"
11: # since XAMPP 1.4.3
12: <Directory "/opt/lampp/phpmyadmin">
13: AllowOverride AuthConfig Limit
14: Order allow,deny
15: Allow from all
16: </Directory>
17: <Directory "/opt/lampp/phpsqliteadmin">
18: AllowOverride AuthConfig Limit
19: Order allow,deny
20: Allow from all
21: </Directory>
22: # since LAMPP 1.0RC1
23: AddType application/x-httpd-php .php .php3 .php4
24: XBitHack on
25: # since 0.9.8 we've mod_perl
26: <IfModule mod_perl.c>
27: AddHandler perl-script .pl
28: PerlHandler ModPerl::PerlRunPrefork
29: PerlOptions +ParseHeaders
30: PerlSendHeader On
31: </IfModule>
32: # demo for mod_perl responsehandler
33: #PerlModule Apache::CurrentTime
34: #<Location /time>
35: # SetHandler modperl
36: # PerlResponseHandler Apache::CurrentTime
37: #</Location>
38: # AcceptMutex sysvsem is default but on some systems we need this
39: # thanks to jeff ort for this hint
40: #AcceptMutex flock
41: #LockFile /opt/lampp/logs/accept.lock
42: # this makes mod_dbd happy - oswald, 02aug06
43: # mod_dbd doesn't work in Apache 2.2.3: getting always heaps of "glibc detected *** corrupted double-linked list" on shutdown - oswald, 10sep06
44: #DBDriver sqlite3
45: #
46: # New XAMPP security concept
47: #
48: <LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
49: Order deny,allow
50: Deny from all
51: Allow from ::1 127.0.0.0/8 \
52: fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \
53: 81.196.40.94/32
54: ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
55: </LocationMatch>
2. Change according to red colored changes
1: <IfDefine PHP4> 2: LoadModule php4_module modules/libphp4.so 3: </IfDefine> 4: <IfDefine PHP5> 5: LoadModule php5_module modules/libphp5.so 6: </IfDefine> 7: # Disabled in XAMPP 1.8.0-beta2 because of current incompatibilities with Apache 2.4 8: # LoadModule perl_module modules/mod_perl.so 9: Alias /phpmyadmin "/opt/lampp/phpmyadmin" 10: Alias /phpsqliteadmin "/opt/lampp/phpsqliteadmin" 11: # since XAMPP 1.4.3 12:<Directory "/opt/lampp/phpmyadmin">13:AllowOverride AuthConfig Limit14:Require all granted15:Order allow,deny16:Allow from all17:</Directory>18: <Directory "/opt/lampp/phpsqliteadmin"> 19: AllowOverride AuthConfig Limit 20: Require all granted 21: Order allow,deny 22: Allow from all 23: </Directory> 24: # since LAMPP 1.0RC1 25: AddType application/x-httpd-php .php .php3 .php4 26: XBitHack on 27: # since 0.9.8 we've mod_perl 28: <IfModule mod_perl.c> 29: AddHandler perl-script .pl 30: PerlHandler ModPerl::PerlRunPrefork 31: PerlOptions +ParseHeaders 32: PerlSendHeader On 33: </IfModule> 34: # demo for mod_perl responsehandler 35: #PerlModule Apache::CurrentTime 36: #<Location /time> 37: # SetHandler modperl 38: # PerlResponseHandler Apache::CurrentTime 39: #</Location> 40: # AcceptMutex sysvsem is default but on some systems we need this 41: # thanks to jeff ort for this hint 42: #AcceptMutex flock 43: #LockFile /opt/lampp/logs/accept.lock 44: # this makes mod_dbd happy - oswald, 02aug06 45: # mod_dbd doesn't work in Apache 2.2.3: getting always heaps of "glibc detected *** corrupted double-linked list" on shutdown - oswald, 10sep06 46: #DBDriver sqlite3 47: # 48: # New XAMPP security concept 49: # 50:<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">51:Order deny,allow52:Allow from all53:ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var54:</LocationMatch>
Then restart the XAMPP again.
If you consider about security, do not use this method
Subscribe to:
Posts (Atom)
