miércoles, 29 de agosto de 2012

Secure random number

Some theory

Well, the next step is to verify the keys of the One-Time-Pad randomly generated by Python's random method

There are many types of methods for checking if the numbers are random.

Characteristics:

  1. Uniformly distributed
  2. No numbers repeated on a specified length
  3. Numbers must be independent of each other
  4. The series should be reproducible
  5. The numbers must be generated quickly

Part of the previous program had to generate the random numbers

Code
In this code I generate random numbers between 0 and 1 to create different keys, now is necesary to verify that this numbers are really random


Test used "Run Test"

In this Test is verified if the hypothesis of a number is really random between two elements, in this case 0 and 1.


Parameters

amount of the first element in this case "0"
amount of the second element in this case "1"
amount of elements
amount of blocks

Regarding the blocks, a block is when the same element is repeated until meet the other element and it starts over with a new block:

For example:
In this case, we have 5 Blocks

Having this elements clearly defined, we can begin seeing how the test works

First, we get the arithmetic mean:

After we got the arithmetic mean, the variance:

Finally we got the probability of Z



Code:
Screen Printing



In this case is randomly, but in mayor of the case arenot randomly
Is randomly = 20%
Not randomly = 80 %
Test was performed 10 times

Sorry, here is more information, the value 1.96 is found in the critical value, it depends of the level of reliability, in this case 95 percent.

Graphics and table:



Here is the table:
1 - a a/2 Za/2
0.90 0.05 1.645
0.95 0.025 1.96
0.99 0.005 2.575







Thanks, have a nice day :D

miércoles, 22 de agosto de 2012

One -Time -Pad

Hola a todos ahora en esta ocasión les tenemos un pequeño programa para encriptar y desencriptar por este método One-Time-Pad

Breve explicación:

1-. Primero se crea las llaves en una archivo de texto, todas las llaves son binarios aleatoriamente
2-. Escribimos nuestro mensaje
3-. Lo Encriptamos

Forma de Encriptación:

Por ejemplo si nuestro mensaje representado en código binario fuera: 0010101
y nuestra llave fuera: 0101010

Por método exor quedaría de la siguiente manera:

mensaje = 0010101
llave = 0101010
Mensaje encriptado = 0111111

Posteriormente se desencripta con la misma llave donde el otro usuario por medio de la libreta sabrá cual es y al finalizar esta llave sera eliminada.

Aquí el código:



Aquí unas impresiones de pantalla:

Aquí se genera las llaves y se nos pide el mensaje

Empezamos a encriptar:


Aquí va encriptando dato por dato hasta completar la frase


En esta imagen si vemos en la parte superior derecha ya nos desifro el mensaje y pasa a borrar la llave usada, aquí solo se muestra en la terminal las demás llave con fines educativos, lo correcto es no mostrarlas.

y posteriormente el otro usuario dará su mensaje y se repetirá el proseso:



Thanks


domingo, 12 de agosto de 2012

My message

Hint: Lyrics



yak kr _a ev vetdzsv_ trdfre brdr v_r.adrdev
yak kr ,re w,adve _a ev hv_
ua_uv ry cgvurua rcv, da.r_tv
kr _a vjzefv_ ,ae bav.re brdr ta_cgzefrdev
ryadr ev .r_ur_ ea,a .rz,e
kr _ruzv v_fdvxr tyata,rfve
bvda .v _zvxa r dv_ahrd.v ve .z .r_vdr
fv ,a ta_wzvea cgv cgzezvdrpp

r.rdfv r ,r r_fzxgr
v_fdvxrdfv .z hzur
,,v_rdfv u daere
tr_frdfv tr_tza_ve
bz_frdfv trdztzrepp

r.rdfv r ,r r_fzxgr
dasrdfv ea_dzere
fa.rdfv ,r .r_a
rsdzdfv ,r bgvdfr
vetdzszdfv bavezre
r.rd ta.a r_fvepp

ryadr ,ae r.adve ugdr_ ea,a g_ z_efr_fv
bvda ,a _gvefda ve r,dvhve
trur .z_gfa ve z.badfr_fv
bvda .v _zvxa r dv_ahrd.v ve .z .r_vdr
fv ,a ta_wzvea cgv cgzezvdrpp

r.rdfv r ,r r_fzxgr
v_fdvxrdfv .z hzur
,,v_rdfv uv daere
tr_frdfv tr_tza_ve
bz_frdfv trdztzrepp

r.rdfv r ,r r_fzxgr
dasrdfv ea_dzere
fa.rdfv ,r .r_a
rsdzdfv ,r bgvdfr
vetdzszdfv bavezre
r.rd ta.a r_fvepp

vdve !gefa ta.a fv eav
fg _a ersve tgr_fa fv vebvdv
k uveva brdr ezv.bdvpp

r.rdfv r ,r r_fzxgr
v_fdvxrdfv .z hzur
,,v_rdfv uv daere
tr_frdfv tr_tza_ve
bz_frdfv trdztzrepp

r.rdfv r ,r r_fzxgr
dasrd.v ea_dzere
fa.rdfv ,r .r_a
rsdzdfv ,r bgvdfr
vetdzszdfv bavezrepp

r.rd ta.a r_fve
r.rdfv r ,r r_fzxgr





GOOD LUCK