How random is /dev/random? Visualizing the output of /dev/random using hexdump, dd, and python

Screen Shot 2015-05-30 at 8.25.23 AM

I wrote a python script that will plot the output of /dev/random in a few ways so you can see just how random it is.

Make a line plot:

Screen Shot 2015-05-30 at 9.08.52 AM

Make a histogram:

Screen Shot 2015-05-30 at 9.08.02 AM

 

Options:

Do be careful when using the dd command. It can wipe out your filesystem if you set the outfile incorrectly. I’d recommend not changing the option of=”./randfile”.

Edit the block size and/or block count in *.sh to change the output resolution:

Screen Shot 2015-05-30 at 8.33.37 AM

You may need root privileges to use the dd command.

Remember that on OSX, /dev/random and /dev/urandom are identical.  On linux, to get 100 blocks as I have, you may have to use /dev/urandom (unlimited random). The linux case is probably more interesting as the outputs are different.  How exactly DO they differ?

OSX is known to use Yarrow-160 a cryptographic algorithm that makes use of hash functions (specifically SHA1) to create “unlimited” seemingly-random bits from a finite entropy pool.

As far as I know, linux does not. Linux will wait for more entropy when /dev/random is used as opposed to /dev/urandom.

See personal page and github repository.

Posted in Stuff

Boot Linux from a USB flash drive on a Macbook

Originally posted on AstroFloyd's blog:

In order to install Linux on the replacement of a crashed hard-disc drive in a 2006 Macbook Core duo, I wanted to boot Linux from a USB flash drive in order to then install it. While this is trivial on most PCs, it turned out not to be on an old Macbook.

View original 872 more words

Posted in Stuff

Do copies of Hamlet exist embedded in the digits of pi?

I know Vi Hart discussed it, but she may have not been the first to entertain the idea. Not sure. The question is do they digits of pi contain copies of hamlet?

Yes, yes they do. Not just copies of Hamlet, but actually copies of every book imaginable are contained within the digits of pi an infinite number of times.

Using software package pi and simple shell commands,

pastebin of shell commands

I found that any N digit sequence probably appears within the first 10^N digits of pi [1]; moreover, the sequence would appear about 10 times in the first 10^(N+1) digits of pi, 100 times in the first 10^(N+2) digits, etc.

For example, lets say our sequence is the last 4 digits of my phone number – 1345
That’s 4 digits, so if I scan the first 104 digits of pi, sure enough, my phone number occurs 1 time. If I scan 105 digits, it occurs 12 times. For 109 digits, it occures like 98 times. Its clockwork. See below.

altoidnerd@HADRON:~$ pi 10000|grep -o 1345|grep -c 1345
1
altoidnerd@HADRON:~$ pi 100000|grep -o 1345|grep -c 1345
12
altoidnerd@HADRON:~$ pi 1000000|grep -o 1345|grep -c 1345
114
altoidnerd@HADRON:~$ pi 10000000|grep -o 1345|grep -c 1345
1020

Anyway, so the question is how many digits of pi would we need to search through to likely find about 1 or 2 copies of hamlet in the sequence?

So I got hamlet in plaintext from 2 sources. I found that hamlet when compressed from plain text to a tar.gz archive, the average size was 69 KiB. Therefore, (I think?) that means to represent hamlet as just a binary integer, it would have 69 x 8 x 1024 digits = 565248 digits.

To get the number of digits in base 10, we multiply by log_10 (2) +~ .69 so the base ten hamlet would be like a sequence of about ~390,000 digitsm (0-9).

Ok so back to pi. How many digits of pi must we scan to probably find a string of length 390,000? That would be 10^390000 digits. That’s a lot of pi, but pi has got enough digits to spare. We should see approximately 1 copy of hamlet in the first 10^390000 digits of pi.

Even cooler is that if we just increase the power by 1, we should see 10 hamlets; increase the power by 2, and we should get 100 copies of hamlet. So quickly, we end up with infinite hamlets in the digits of pi. And not only hamlet … this argument should would for any book.

[1] This is not too surprising since pi is believed to be a normal number, though this is unproven.

Tagged with: , , , , , , ,
Posted in computing, Electronics and Engineering, Physics and Mathematics, Stuff

Calculations of the EFG tensor in DTN using the GIPAW method with CASTEP and Quantum Espresso software

One important difference between NQR and NMR is that for NQR, the transition frequency is site specific and cannot be chosen by the experimenter. In NMR studies, the excitation frequency of the nucleus is just the gyromagnetic ratio times the applied field. Thus, the difficulty in NMR is controlling the uniformity of the applied static B. However, the experimenter is free to choose an operating frequency by adjusting B. For NQR, the transition frequency is proportional to the electric field gradient (EFG) at the nuclear site, which is entirely a property of the substance and a function of temperature. While it is theoretically possible to apply a prescribed EFG in the lab, it is unfeasible as the EFG’s in crystal strcutures are often on the order of many kV/m^2. Thus the particular difficulty in NQR spectroscopy is locating the resonance in the first place, which is much like combing the desert if the apparatus runs at a fixed frequency. The home made pulsed superheterodyne spectrometer used in the trial experiments has proven to have excellent resolution. However, it has essentially no ability to perform frequency sweeps as is done in continuous wave methods. The operator must choose a relatively narrow band (< 1 MHz) to target, and design a custom bridge, tank, and receiver configuration just for small band. Band switching is non-trivial with high resolution pulsed techniques.

At one time, it was not possible to calculate the EFG for all but the simplest of structures. However, DFT calculations have become very potent and accessible in the last decade. Beginning in June of 2013, Calculations of the EFG tensor in dichloro-tetrakis-thiourea-nickel NiCl_2 [SC(NH_2)_2]_4 were made using the GIPAW method with closed source CASTEP software (by then graduatre student Dr. Tim Green at Oxford University, with advisor Dr. Jonathan = Yates). Then in October of 2013, Dr. Ari Seitsonen and I repeated the calculation at ETH in Zurich using the open source DFT-GIPAW package Quantum Espresso (QE).

The two calculations show good agreement in many respects and indicate that the 35Cl resonance frequencies in DTN are likely about an order of magnitude lower than initially believed. Because chlorine NQR transitions occurred around 30 MHz in both para-dichlorobenze and NaClO_3, DTN was initally thought to be likely to show 35Cl NQR in the 29-31 MHz band. This was tested first by Robert Baker (REU Student, 2010) and then in 2012-2013 by myself to no avail.

There is no particular reason 35Cl should have to have a resonance in this 30 MHz band. 35Cl NQR measurements have been made in many materials below 18 MHz and above 60 MHz. A high degree of symmetry in a given structure can result in very low NQR frequencies, with correspondingly very poor S/N. Though all nuclei with spin S >= 1 are guaranteed to have at least one non-zero NQR transition frequency, NQR is not always found. This is likely due to poor S/N when the EFG is small and the transition frequency is very low.

Evidence for the validity of the DFT calculations is that the prediction for NaClO3 35Cl NQR matches observation remarkably well. Additionally, since both DFT packages output the full EFG tensor, the NQR transitions for 14N were also predicted by the same calculations. There are sixteen nitrogen nuclei in each unit cell of DTN (right). DTN contains 4 independent thiourea molecules in each unit cell, each having 4 nitrogen centers.

The NQR frequencies calculated by CASTEP and QE for 14N in DTN match very well with those observed in pure thiourea from literature (David H. Smith and R. M. Cotts). The paper by Smith and Cotts quotes NQR in 14N in pure thiourea NQR at 2.6 MHz and 2.0 MHz for inequivalent sites at room temperature. In the absense of any DFT calculation, the 14N resonance in pure thourea would be a best first guess as to the NQR transition for 14N in DTN.

As the NQR frequency at a given nuclear site is directly proportional to Vzz (the electric field gradient, or stretching), crystals with a high degree of symmetry will have low NQR frequencies. Inspection of the crystal structure superficially indicates a widely symmetric nuclear distribution about the chlorine sites, as the thiourea groups are distributed symmetrically and the structure parameters show each Cl is roughly equidistant to both adjacent Ni nuclei.

The quadrupole coupling constant and NQR transitions
The quadrupole coupling constant Cq is defined as

 Cq = e*Vzz*Q/h [1]

where Vzz is the largest absolute eigenvalue, e is the electron charge, Q is the quadrupole moment and h is planck's constant.

We consider a nucleus of spin S and define

 A = eVzzQ / (4S(2S-1)) [2]

where S is spin and Q is the quadrupole moment. Then the NQR frequency or (frequencies) are given by

 f_nqr = 3|A| / h (2 |m| +1) [3]

where m is the lowest of the two levels m and m+1 over which a transition has occurred. For integral spins there are S unique transitions. For half integral spins there are S – ½ unique transitions.
NQR is observed in nuclei with I=3/2, I=5/2 and I=7/2. For I=1/2., there are no transitions. The I=5/2 and I=7/2 are indeed complicated, but for I=3/2 there is a degeneracy that causes there to be one frequency of half the quadrupole coupling constant, which makes the single transition frequency in the case of I=3/2 equal to one half the quadrupole coupling constant Cq = eVzzQ/h = e^2Qq/h.

NQR Frequencies for half-integral spins
Chlorine has I = 3/2 so there is only 1 transition. Using I=3/2 in the formula above, we obtain

 f_nqr = (1/2) eVzzQ/h = (1/2) Cq [4]

for axially symmetric field gradients. For non-axially symmetryic gradients, we define the assymetry parameter η = (Vxx-Vyy)/Vzz. η=0 in the axially symmetric case, where Vzz is the only nonzero component. When η is non-zero, the transitions for I=3/2 are

 f_nqr ~ (1/2) eVzzQ/h * (1 + 1/3 η^2)^(1/2) [5]

In general for half integral spin of I = n/2 n 3, 5, 7,... use what is given in Hahn and you should find the coefficients are 3/10, and 3/20 for I=5/2

 f_nqr_[5/2 --> 3/2] = (3/10) eVzzQ/h [6]
 f_nqr_[3/2->1/2] = (3/20) eVzzQ/h [7]

NQR frequencies for integral spins
For integral spins, we use the formula [2] again. For for I=1 and an axially symmetric field gradient (η=0) , the NQR transition frequency is

 f_nqr = (3/4) eVzzQ/h = (3/4) Cq [8]



EFG->C: https://github.com/tfgg/magres-format/blob/master/magres/constants.

CASTEP EFG DATA (DTN – 35Cl)
relaxed
Cl 1 Cq: 8.4298 (MHz) Eta: 0.1272
Cl 2 Cq: 0.1705 (MHz) Eta: 0.5898
Cl 3 Cq: 0.1866 (MHz) Eta: 0.5340
Cl 4 Cq: 8.4513 (MHz) Eta: 0.1264
unrelaxed
Cl 1 Cq: -15.7965 (MHz) Eta: 0.0089
Cl 2 Cq: -16.9778 (MHz) Eta: 0.0048
Cl 3 Cq: -16.9515 (MHz) Eta: 0.0048
Cl 4 Cq: -15.8271 (MHz) Eta: 0.0089

QE EFG DATA (DTN – 35Cl)
relaxed
 Cl 1 Cq= 9.4969 MHz Eta=-0.00000
 Cl 2 Cq= -0.9388 MHz Eta= 0.00000
 Cl 3 Cq= 9.4869 MHz Eta= 0.00000
 Cl 4 Cq= -0.9298 MHz Eta= 0.00000

CASTEP EFG DATA (DTN – 14N)
relaxed
N 1 Cq: -3.7067 (MHz) Eta: 0.3400
N 2 Cq: -3.3560 (MHz) Eta: 0.4226
N 3 Cq: -3.6918 (MHz) Eta: 0.3463
N 4 Cq: -3.3621 (MHz) Eta: 0.4256
N 5 Cq: -3.6917 (MHz) Eta: 0.3468
N 6 Cq: -3.3533 (MHz) Eta: 0.4231
N 7 Cq: -3.7068 (MHz) Eta: 0.3410
N 8 Cq: -3.3535 (MHz) Eta: 0.4228
N 9 Cq: -3.6920 (MHz) Eta: 0.3466
N 10 Cq: -3.3611 (MHz) Eta: 0.4251
N 11 Cq: -3.7067 (MHz) Eta: 0.3409
N 12 Cq: -3.3524 (MHz) Eta: 0.4230
N 13 Cq: -3.7073 (MHz) Eta: 0.3399
N 14 Cq: -3.3563 (MHz) Eta: 0.4225
N 15 Cq: -3.6927 (MHz) Eta: 0.3469

unrelaxed
N 1 Cq: 3.0165 (MHz) Eta: 0.8408
N 2 Cq: -2.6850 (MHz) Eta: 0.9198
N 3 Cq: 3.0154 (MHz) Eta: 0.8423
N 4 Cq: -2.6885 (MHz) Eta: 0.9216
N 5 Cq: 3.0164 (MHz) Eta: 0.8419
N 6 Cq: -2.6841 (MHz) Eta: 0.9213
N 7 Cq: 3.0179 (MHz) Eta: 0.8414
N 8 Cq: -2.6854 (MHz) Eta: 0.9186
N 9 Cq: 3.0188 (MHz) Eta: 0.8421
N 10 Cq: -2.6833 (MHz) Eta: 0.9207
N 11 Cq: 3.0214 (MHz) Eta: 0.8411
N 12 Cq: -2.6802 (MHz) Eta: 0.9177
N 13 Cq: 3.0199 (MHz) Eta: 0.8406
N 14 Cq: -2.6798 (MHz) Eta: 0.9189
N 15 Cq: 3.0198 (MHz) Eta: 0.8417
N 16 Cq: -2.6788 (MHz) Eta: 0.9203

QE EFG DATA (DTN – 14N)
 relaxed
 N 45 Cq= -3.5069 MHz eta= 0.36826
 N 46 Cq= -3.5084 MHz eta= 0.36870
 N 47 Cq= -3.5084 MHz eta= 0.36870
 N 48 Cq= -3.1864 MHz eta= 0.38355
 N 49 Cq= -3.1864 MHz eta= 0.38355
 N 50 Cq= -3.1880 MHz eta= 0.38408
 N 51 Cq= -3.1864 MHz eta= 0.38355
 N 52 Cq= -3.1864 MHz eta= 0.38355
 N 53 Cq= -3.1880 MHz eta= 0.38408
 N 54 Cq= -3.5069 MHz eta= 0.36826
 N 55 Cq= -3.5084 MHz eta= 0.36870
 N 56 Cq= -3.5084 MHz eta= 0.36870
 N 57 Cq= -3.5069 MHz eta= 0.36826
 N 58 Cq= -3.1880 MHz eta= 0.38408
 N 59 Cq= -3.1880 MHz eta= 0.38408
 N 60 Cq= -3.5069 MHz eta= 0.36826
Q= 2.04 1e-30 m^2
 


For NaClO3, CASTEP arrived at an average NQR frequency (over 4 sites) of 28.9 MHz. For chlorine in DTN, CASTEP calculated NQR at 8.5 MHz (unrelaxed) and 4.5 MHz (relaxed). For 14N in DTN, the calculation yields 2.9 MHz and 1.6 MHz for inequivalent sites in the relaxed EFG calculation. The difference between the relaxed and unrelaxed calculation lies in the structural data preparation. In the unrelaxed case, structure data from direct measurements in literature is fed directly into CASTEP and used. In the relaxed case, the structure parameters itself are adjusted using GIPAW, and then the EFG is calculated.

Posted in Stuff

Meeting – October 8, 2014 | Hashes

Altoidnerd:

Crackin

Originally posted on University of Florida Student Infosec Team:

Hi SITers!

This week’s presentation will introduce the science behind hashes such as SHA2/MD5 and how they are commonly used on Linux systems. Additionally, this presentation will introduce the hashmap datastructure and how it is implemented in the C programming language. We will discuss how a poor implementation can result in a vulnerability.

Make sure to bring your laptop with the VMs that we installed at the beginning of the semester! If you did not get a chance to download them, find an officer and we’ll give you them.
[Be Social!]
IRC: #ufsit on Freenode
[Time and Location]
Wednesday 7:00pm – 9:00pm
CSE E309

View original

Posted in Stuff

Brace yourself… cool-old-term is coming!

Altoidnerd:

Just wow. Too bad its not arch.

Originally posted on Swordfish's Labs:

Since when I played Fallout III for the first time I have always wanted my terminal to look like those old jittery CRT screens that you loved in the game. Sadly there was nothing like that on Linux… Till I decided to make one myself!

In the last six months I dedicated some of my spare time to create a terminal emulator which had to look that way, but also had to be customizable and reasonably lightweight. Now the project is near completion I want to share with everyone the result!

The application is written using QtQuick 5.2 and uses as engine the Konsole QML port made by Canonical (https://code.launchpad.net/~ubuntu-terminal-dev/ubuntu-terminal-app/plugin).

If you are a graphical designer and you want to help the project feel free to contact me. I’m quite bad with gimp and I would be really glad if someone created a couple of frames and a good icon…

View original 28 more words

Posted in Stuff

The cost of artificially pumping a low volume altcoin: pumping the alt markets by yourself with the BTC/LTC “pump machine” strategy

1jgDiMN

For this article we regard ALL prices in crypto-crypto units, and unless otherwise noted, denominated in units of BTC. Therefore bitcoin costs 1, LTC (today) costs ~.009 BTC/LTC, etc…

I have noticed there is a way to burn bitcoin in order to raise the price of an altcoin, assuming low volume, and assuming there is a secondary market, such as LTC, on which the coin is trading. I call it the pump machine. It goes as follows:

Method of spending BTC to temporarily pump the bitcoin price of a low volume coin, which will be denoted SHT:

1) Suppose you only have 1 BTC

2) Buy as much SHT as you can with 1 BTC

Problem seeing this image? Try http://i.imgur.com/NasRLSj.png?1

It doesn’t matter what coin SHT represents in this example, but I choose DRK because I will soon describe trading coins which reach price parity with LTC, and why that can be very good.

3) Go to the LTC/SHT market and sell all the SHT for LTC. Now you have a bunch of litecoins.

http://i.imgur.com/XNdOLf0.png?1

Casually sell the SHT for LTC.

4) Go back to the BTC markets – this time, the BTC/LTC trading floor. Take the LTC and sell it for BTC. You’ll now have a bit less than 1 BTC (most likely).

http://i.imgur.com/4Ghz3Ww.png?1

Get bitcoin back…

5) Now that you hold BTC (perhaps a bit less than 1) go back and pump SHT! Buy .9887 BTC worth of SHT, rinse and repeat.  If the markets are dull enough, you can make it seem, for a while, like more bitcoin than you could possibly spend on SHT is buying the SHT up.  In the end you’ll pay for this deception, but in the short term, it’s a pump machine.

6) Continue the cycle. Watch your bitcoin stash go melt away slowly as you literally pay to pump the price. It’s a bit like a carnot engine.

———————————-

Consider donating to keep altoidnerd.com ad free.  13xdMqkaVKkHKT3ZZx5ikAvQUEkzqpDkDb

Coming soon: the advantage of trading an alt which has reached price parity with LTC. Complete with math.

tytyvm.

Tagged with: , , , , , , , , , , , , , ,
Posted in Bitcoin, Electronics and Engineering, Physics and Mathematics, Stuff

It may be time to buy some LTC again. Here’s why. The golden rules for altcoin trading.

Problem with image? See it on imgur here http://i.imgur.com/6ibi1z1.png?1

Litecoin price in BTC on the btc-e exchange, for as long as bitcoinwisdom.com can remember. We are at about all time lows.

This blog post is a glorified (with some images and minor changes) copy pasta of my post on /r/cryptomarkets.

LTC – how low can it go? It might be time to take a shot with LTC for a potential bitcoin profit.

Problem with image?  Go to http://i.imgur.com/RL7HENT.png?3

Past performance is no indication of future…oh whatever. Let’s get some LTC. 1) it’s old 2) its inflation rate is very slow 3) it’s not bitcoin 4) historically speaking, this is an OK price.  5) LTC enjoys special status in the cryptocurrency world as a secondary market, and should always be watched out of the corner of one’s greedy eye.

I have done this with LTC a few times – the best of which was last November. Priced in BTC, it is now near parity with DRK and below .01 … which isn’t far from the price I think I paid for a bunch of LTC right before the boom in November, when I started writing about trading in /r/cryptomarkets with “the golden rules for alt trading.”

One thing that makes LTC different from other scrypt alts is its very slow ditribution – it’s just as slow as bitcoin. To me, that makes it still attractive as a swing trade, because big investors are probably thinking about it. What do y’all think?

BTW, just looked. I decided to buy lots off LTC last year at .008, and it’s not far from this mark. I wrote the golden rules to this sub from a 5-star hotel (I don’t stay in those) thanks to that trade. Good times…

Tagged with: , , , , , , , , , , ,
Posted in Bitcoin, Electronics and Engineering, Physics and Mathematics, Stuff

Sexism in computer science? We will find out.

Please take this short poll:

Which do you prefer?

A) while loops
B) baking cookies

Posted in Stuff

Hexadecimal word games. Not fail = foresee!

If you write “fail” as 0x0FA11, not fail becomes 0xF05EE..or “foresee!”

It’s fun to try and write words in hex, like “deadbeef” of “cafebabe.” If we allow ourselves certain 1337 notations for letters, we can write even more words as Hexadecimal integers like “5ca1ab1e.” Pretty cool!

What is not scalable? Well that’s computable … not 0x5ca1ab1e is 0xa35e54e1. This isn’t a word.

But as I demonstrated above, much fun can be had by taking binary operations on these integers. Not fail is foresee. Can you find any others?

20140729-000507-307862.jpg

20140729-000508-308047.jpg

Tagged with: , , , , , , , , , , , , ,
Posted in Electronics and Engineering, Physics and Mathematics, Stuff
“recent” posts
Follow

Get every new post delivered to your Inbox.

Join 64 other followers