Wednesday, April 2, 2008
Wednesday, January 30, 2008
Encryption with Digest#SHA
There are several levels of encryption you can use in Digest#SHA.
- Digest::SHA1.hexdigest() - produces a 40 characters of hexadecimal digits.
- Digest::SHA256.hexdigest() - produces a 64 characters of hexadecimal digits
- Digest::SHA384.hexdigest() - produces a 96 characters of hexadecimal digits
- Digest::SHA512.hexdigest() - produces a 128 characters of hexadecimal digits
You can check it by trying the following.
Note: To execute the commands, press Enter after typing.
- Open your console.
- Change the directory to any of your existing rails application.
- Type ruby script/console.
- Type a = Digest::SHA1.hexdigest(“test”).
- Type a.length. It will display the length of the strings in the variable a.
- Repeat step 4 but replacing SHA1 with SHA256, SHA384, or SHA 512.
Depending on your required level of security you can choose among the different SHA levels. If you require the highest level of encryption then you can use SHA512.
Most of its use include encrypting passwords before saving it to the database. You can also use it to encrypt files.
Peace!
Monday, January 28, 2008
I found Rails
Rails is a web framework which is powered by Ruby a scripting language. It follows the Model-View-Controller (MVC) architecture. Which means there is a separation between data(database/Model), logic(business rules/Controller), and presentation(user interface/View).
- Convention over configuration. - You can get up and running without going through the process of repeating the same configurations in your code. All you have to do is to set it once and your done. Configure your database connections and you can use that connection wherever in your code you want.
- Don't Repeat Yourself (DRY) – No more copying and pasting the same code. Just define the methods(functions, actions, whatever you may call it) once and use it anywhere in your code. If you want to make changes to your methods then you can just easily change it in one place.
- Agile development – Rails follow the Agile development process. It's sort of like more on user demand based approach. List down the initial requirements and layout the basic skeleton of the application. Acquire further requirements suggested by the user and implement those requirements. And the cycle is repeated until an application is acceptable.
Note: I'm not an expert so some of the terms and ideas that I've wrote here might be incorrect. Feel free to give comments. Thanks!
Saturday, January 19, 2008
I See Ruby
Ruby is created by a clever japanese guy named Yukihiro Matsumoto (hands down to this guy) commonly known as Matz in 1993. One of the goals why Matz created ruby is to make programmers enjoy programming and be more productive. Finally I've found a language that is literally makes a programmer happy. I hope I get to meet Mr. Matz in the future.
The syntax of Ruby is clean and simple(no more messy braces or semicolons). Control statements are much tighter. And learning object-oriented concepts is easier for me than with other languages like C/C++ or Java.
Ruby is the language that powers Rails. If you have tried visiting websites that is based on Rails then that site is definitely has Ruby behind it. If you learn Rails then you are also learning Ruby. But the best way to learn and understand how Rails works is to learn and understand Ruby first.
Aside from powering Rails, Ruby can also be used in many different programming disciplines like creating GUI applications, handling databases, console apps or anything you can think of. I've been considering using Ruby as a replacement for creating desktop apps(since I use VB6 and got tired of it).
There are a lot of resources on the internet that you can find to begin your quest in learning ruby. You can begin by visiting www.ruby-lang.org/en/ where you can find basic information about Ruby among others.
Ruby shines! Thanks Matz!
Saturday, January 5, 2008
First Encounter With Ruby On Rails
Even though I'm haven't yet learned of the things that I need to learn about it, I can see myself working and living with RoR in the future.
More to come in the future as I work my way on trying to me good enough for sharing what I've learned from RoR.
More power to Ruby on Rails!