There are some terms that I’m hearing more and more in the programming world, CRUD and REST.

What is CRUD?

CRUD is an acronym for Create Read Update Delete.  As a programmer / developer most of my time is spent doing crud operations (well at least in my current position).

What is REST?

REST is a acronym for Representational state transfer. Restful Development is a platform independent management and architectural style advocating pragmatic practice with industry standards.  Rest was first coined by Ron Fielding in his doctoral dissertation “Architectural Styles and the Design of Network-based Software Architectures” .

For new programmer OOP can be a hard concept to wrap you mind around. In this post my goal is to go over some of the concepts of OOP.

Wikipedia’s definition of OOP is: ”Object-oriented programming (OOP) is a programming paradigm that uses “objects” and their interactions to design applications and computer programs. Programming techniques may include features such as encapsulation, modularity, polymorphism, and inheritance. It was not commonly used in mainstream software application development until the early 1990s. …. ”

History of OOP

SIMULA I (1962-65) and Simula 67 (1967) are the two first object-oriented languages. Simula 67 introduced most of the key concepts of object-oriented programming: both objects and classes, subclasses and virtual procedures, combined with safe referencing and mechanisms for bringing into a program collections of program structures described under a common class heading (prefixed blocks).

 Simula 67 was a groundbreaking system that has inspired a large number of other programming languages, and some of these include Pascal, Lisp and in the .net world #C and VB are the most popular. OOP was also important for the development of Graphical user interfaces. This paradigm of programming has also played an important role in the development of event-driven programming.

Explanation of OOP concepts

The term “Object,” that gives OOP it’s name, refers to a conceptualobject that represents an item in our program or system. This could be anything from an on-line form or a computer file, to a real world object such as a car. Being a car guy this is analogy helps me the most.

This representation consists of attributes – the characteristics of our object; and methods – a set of functions and calculations that are either performed to modify the object itself, or are involved in some external effect.

The term “Class” represents the definition (or classification – class) of our object. For example, if we were to write a class called “car”, we could create any number of instances of that class – say “Ford”, “Honda” and “Chevy”. Each of these instances is an Object. This illustrates that a class is effectively a set of objects that all share common attributes.

The “car” object can do a number of methods or “actions”: (beep, start engine, turn on lights, and etc.) Some methods can accept parameters, for instance. Say your car class has a method called “wipers_on”, this method take a parameter for the speed of the wipers i.e. (slow, medium, and fast).

Polymorphism refers to the ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes. For example, given a base class “shape“, polymorphism enables you to define different area methods for any number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area method to it will return the correct results. Polymorphism is considered to be a requirement of any true object-oriented programming language (OOPL).

Inheritance is the process by which objects can acquire the properties of objects of other class. Inheritance provides reusability, like, adding additional features to an existing class without modifying it. This is achieved by deriving a new class from the existing one. The new class will have combined features of both the classes.

The Process class is very useful, I use the Process class for running third party and legacy programs. For example, I have an app written by a vendor that I need SQL functionality as well as the programs operation. These SQL tables contain data like when the program started, the name of the file processed, the status of the operation (running, failed, or successful), and time the process finished. The vendors program is a command-line program written in C++ unfortunately I couldn’t even use interop.

The StartInfo property has list of the properties and some of these are:

Filename  value = String
Arguments value = String
WorkingDirectory value = String
UseShellExcute value = Boolean
RedirectStandardError value = Boolean
RedirectStandardOutput value = Boolean
CreateNoWindow value = Boolean

Some of the methods are:

Start returns Boolean
CloseMainWindow returns Boolean
Kill 
Dispose

Imports System.Diagnostics

Module Module1
   Sub  Main()
      Dim instance As New Process
      instance.StartInfo.FileName = "notepad.exe"
      instance.StartInfo.WorkingDirectory = "C:\"
      instance.StartInfo.UseShellExecute = True
      instance.Start()
      instance.WaitForExit()
   End Sub
End Module

This is the second in a series of post covering Cryptography in .net or the System.Security.Cryptography namespace. 

RC2

RC2 method of encryption (block cipher). This algorthim also uses the symmetric method of encrypting data. Unlike DES, RC2 uses variable key sizes giving greater protection against bruteforce attacks. 

RC2 ciphers are vulnerable to related-key attacks using chosen plaintext. RC2 is relatively efficiently implemented and is well documented.

The properties and methods are much the same for this as in my post Cryptography in .NET I’m not going to post any code.

 For more information:

just googleit

 

My Disclaimer:

The purpose of this post is only to show methods of encryption used in the .net framework. In no way do I claim to be any expert in cryptography. Again my only goal here is to show the methods used in the .net framework. This post was inspired both by “Better Know a Framework” from DotNetRocks. And a talk by Jeff Moser, given at the Indy Code Camp 2008.

The System.Security.Cyptopgraphy namspace contains may classes and methods for encrypting and decrypting data. In this post I’m going to discuss the DES method of encryption. In later posts I plan on discussing each of the implementations symmetric and asymmetric cryptography in the .net framework.

The DES method uses the symmetric encryption algorithm (also called a cipher). Symmetric encryption is fast and well suited for encrypting large quantities of data.

DES Concerns

The DES algorithm is now considered by today’s standards to be insecure, mainly do to the fact that it uses a 56-bit key. Another disadvantages of DES is that because it uses symmetric encyption it presumes that two parties have already agreed on a key. The key itself cannot be encrypted and depends heavily on a secure channel to send the key to the other party. For example: If you send the key to your friend in an email, but your email was captured. Or you could relay the key over the phone, if your phone were tapped or someone overheard your conversation. The result is a third part has your key.

 The following code is a very basic example on how to encrypt a text file using DES. 

 

Imports System.Security.Cryptography
Imports System.Text
Imports System.IO

Module Module1

    Sub Main()
        MyDESEncyption()
    End Sub

    Sub MyDESEncyption()

        Dim input As String = "C:\TestFile.txt"
        Dim output As String = "C:\TestFile.txt.enc"

        'File Stream object
        Dim infile As FileStream = New FileStream(input, FileMode.Open, FileAccess.Read)
        Dim outfile As FileStream = New FileStream(output, FileMode.OpenOrCreate, FileAccess.Write)

        'Create Symmetric Algortithm object as a new DES Algorithm object
        Dim DESAlg As SymmetricAlgorithm = New DESCryptoServiceProvider

        'MustOverride method that generates a random key
        DESAlg.GenerateKey()

        'Read plain text file
        Dim fileData(infile.Length - 1) As Byte
        infile.Read(fileData, 0, CType(infile.Length, Integer))

        'Create the ICryptoTransform object
        Dim encytptor As ICryptoTransform = DESAlg.CreateDecryptor

        'Create the CryptoStream object
        Dim encryptStrm As CryptoStream = New CryptoStream(outfile, encytptor, CryptoStreamMode.Write)

        'Write to the CryptoStream
        encryptStrm.Write(fileData, 0, fileData.Length)

        'Close the file hanles
        infile.Close()
        outfile.Close()

    End Sub
End Module

For more information on DES cyprography:

This is my first blog post… In this blog I hope to talk technology and about my growing skillz as a developer.

Follow

Get every new post delivered to your Inbox.