Ruby SHA-512 Password hashing + stretching

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def generatePassword(plainPassword, salt)
     require 'digest/sha1'
     require 'base64'
     salted = plainPassword + "{" + salt + "}"
     digest = sha512(salted)
     # Stretch the password
     for i in 1...5000
          digest = sha512(digest + salted)
     end
     Base64.encode64(digest)
end
 
def sha512(s)
     Digest::SHA2.new(512).update(s).digest
end
Categories: Ruby, Tech | Leave a comment

Awesome Wit

Please go support it. I said please. So you must click no matter what. http://awesomewit.com

 

Categories: Tech | Leave a comment

Fitness and a new chinup bar

I did lots of thinking about my health and fitness recently. I could write an entire essay on those thoughts, but I won’t because I’m too lazy to write and it all boils down to this fact: I NEED TO WORKOUT.

So. I bought an indoor chinup bar from homegym.sg recently. I have decided to do 10 chinups everyday as a start. The chinup bar has a very wide grip. I suck at doing widegrip pull ups. I can do 17 pull ups on a normal grip, but I can barely do 7 on a wide grip. lol. I think I’m getting weaker, but I think it also has to do with the friction base chinup bar (I choose to believe the latter). The way the bar is designed forces me to do pull ups in a very straight-back manner, if not it will lose its grip on the wall and I will fall off and die. Very smart design, now I have to work out in a more siong posture. Me Gusta.

I also tried to enjoy running, but I don’t. The only time I run (after leaving the army) is when I promise myself beer after that. It worked for a few long runs and it really feels great to drink beer after running. But the beer is not doing me any good la. I have sinusitis and beer will worsen the inflammation. So I stopped

Therefore, instead of forcing myself to run. I have decided to join a Muay Thai club. I think it will be much more fun to do cardio in Muay Thai than in running la. I’m still searching for a club to join. Muay Thai is so damn commercialised these days. Back then 5 years ago, I could learn Muay Thai for $30/month. I think it costs at least $100+ now? I think I’ll stick to a budget of $50-$60/month, I just have to spend more time searching.

Anyway. Its a good start la. Merry Xmas everyone.

Categories: Fitness | Leave a comment

Appreciating the present moment

Life will suck if you constantly think that you should be doing something else. Life will rock if you realize you are already doing the best thing ever.

http://zenhabits.net/happy/

Categories: Note to self | Leave a comment

Focus

Focusing is about saying no.

Categories: Note to self | Leave a comment

Spending Time

We often feel the pinch when money is not well spent. But do we feel the same for time?

Categories: Note to self | Leave a comment

Random Act of Kindness

image

image

image

I love cats.. except for the fat one under my block.

Categories: Personal | Leave a comment

The refactoring catalog

http://www.refactoring.com/catalog/index.html

Categories: Tech | Leave a comment

Symptoms

Don’t fix symptoms if possible, so as to serve as a reminder that a deeper problem is present (the root cause).

Categories: Note to self | Leave a comment

Hello world!

Finally decided to create a blog after 12903120371237 years. Will try to update at least once a week :)

Categories: Personal | 2 Comments