How many years
Posted on Thursday, March 22nd, 2018 at 3:42 pmwith out a new post?
with out a new post?
Someone in my office asked me to hide image URL. The problem is, we’ve a bunch of pictures of students and we don’t want any one to download all of them. The pictures are named by student ID, so it will be easy to write a small code to iterate all ID and download all the pictures. That’s why we need to hide the image URL.
At first, I want to make a hash function. So, it will be harder to break. However, we need a storage to store all hash, either in database or in file, which is I don’t want to . So, hash is gone. The other choice is encryption.
What I did is to write two code, first one is to generate an encrypted text from student id. Then, the second code, convert the encrypted text back to id. So, the image URL will include the encrypted text instead of picture’s name. So, instead of
http://www.foo.com/image/512345.jpg
the url will be
http://www.foo.com/image/get_picture.php?hash=21342u987891234
To do this, I use mcrypt function in php to encrypt and decrypt, this is nothing special.
However, I feel like this method will be a victim of known-plaintext attack. Because the website that shows this picture also shows student ID and everyone can guess that the picture’s name should be the ID itself. So, I would like to change the key periodically. So, I make a cron script to change the encryption key every day. It will be harder to crack the encryption.
The code is here
Out of the night that covers me,
Black as the pit from pole to pole,
I thank whatever gods may be
For my unconquerable soul.In the fell clutch of circumstance
I have not winced nor cried aloud.
Under the bludgeonings of chance
My head is bloody, but unbowed.Beyond this place of wrath and tears
Looms but the Horror of the shade,
And yet the menace of the years
Finds and shall find me unafraid.It matters not how strait the gate,
How charged with punishments the scroll,
I am the master of my fate:
I am the captain of my soul.
Like most people, I need a device for reading/internet surfing/gaming/etc. in a toilet (you don’t ? really?). The criteria are simple: small, lightweight, large enough screen, long battery life, good internet connection, support many formats and sit comfortably on my lap.
HP 300LX Handheld PC
Let’s start with the old guy. On the top left, you got HP 300LX. It is a pocket-pc (handheld pc, to be exact) with Windows CE 2.0. I got it from Ebay with very cheap price and it works very well. The problem is, it doesn’t have built-in Wifi. So, I bought a PCMCIA Wifi card, yes, the device has a PCMCIA and a CF slot. Then, the next problem comes, using Wifi will drain your battery (it uses AA batteries) in a matter of minutes. So, you need to plug the AC adapter all the time. Moreover, the keyboard is too small. Well, I can do a short not typing from time to time, but it’s a painful process. For the ebook reading, the screen is nice but too small and you can’t read any modern ebook format, so, just stick with .txt or .pdb then.
The good:
The bad:
The ugly:
iPod Touch
Next one, top middle, is an Apple product, an iPod touch. I’ve been an Apple zealot for sometime, but now, I’m converted. iPod touch is very nice ebook reader device with nice screen and support many formats (with a handful of ebook reading applications). The problem is, the screen is too small. You have you focus your eyes on that small screen and that will hurt your eyes easily. I really like it as internet device, PDA and game console. But as an eBook reader, I don’t like it much.
The good:
The bad:
The ugly:
Fujitsu Stylistic Tablet
The top right is a tablet from Fujitsu (Stylistic 5xxxx somthing). Again, I got it from EBay for $50 something. It has a 233 MHz CPU (slower than iPod touch!!) and Windows 2000. It can access Internet though a PCMCIA Wifi card (I just use the one I bought for the pocket PC). Because it’s running windows, plenty of applications and games are available. However, like most second-hand notebook/tablet, the battery is not great. I can use it for 1.5-2 hrs when I first got the device. Then, it is down to 0.5-1 hrs, with is enough for a toilet session but it’s annoying. Beside, the virtual keyboard is stupidly bad.
The good:
The bad:
The ugly:
Asus EEE PC 900
Next one, because I decided to convert from Apple geek to something else, so I sold my macbook to someone and got a netbook. I don’t use macbook in toilet because of its size and also its temperature. A netbook seem to be a good compromise between a main computer device and a toilet device, which I found out that it’s not true. The problem of the netbook is that it is not design to be used on your lap for a long time. You have to bend your neck in a great angle to read the screen, and that is a painful position. Anyway, I keep the netbook for my main computer device and find something else for my toilet.
The good:
The bad:
The ugly:
Nokia N810 Internet Tablet
In the center is Nokia 810 Internet Tablet, I decided to try a mobile internet device again. This time, it’s not from Apple. It’s a great device with lots of features. You can even play Flash game or watching youtube on it. However, the problem is that it is using not-so-popular OS, applications and games are scratch. You will love it as an Internet device if you use only web-browser. But for ebook reader, games, other applications, it sucks.
The good:
The bad:
The ugly:
Sony EReader PRS505
On the bottom right, you got a Sony ereader PRS505. I bought this because of NungNing, she got one and she loves it. Beside, I really want one for sometime. As an ebook reader, it’s perfect. But, as an Internet device, it’s …… nothing. Well, it’s an ebook reader 🙂
The good:
The bad:
The ugly:
Samsung Galaxy Spica
The last and the current device I’m using in the toilet now is a mobile phone, with Android OS. You can see it at the bottom of the picture. It’s pretty much like iPod touch, but with GPRS/EDGE connection, you can access Internet in any toilets.
The good:
The bad:
The ugly:
Classic.
http://xkcd.com/720/
The new patch of my life is committed and accepted. Let’s see whether it’ll generate any dependency or conflicting bugs…….
I usually work at night, like most programmers I know. But recently, I wake up early, i.e., before sunrise, and somehow I can accept it. Isn’t it a sign of old age?