IRohitable | .NET, SQL Server, Ruby on Rails and everything related to Software

2 Password Managers that can simplify your life

by Rohit 20. July 2014 20:45

I don't know how you manage your passwords but I am finding it difficult to keep track of all my passwords. From often changing bank passwords to credit card PINs, it is really difficult to keep these details secure and accessible.

I came across two tools which can really simplify life:

(1) F-Secure Key

It is a light-weight tool which you just install on your PC or Smartphone and set one master password. This master password is used to encrypt the data file using AES-256. The data file is stored on your PC. You will ask there are several tools which perform similar tasks and are freely available. Yes, but what makes F-Secure Key different is that it can synchronize your protected data across devices like smartphones. This feature is not FREE and available with a minimal subscription fee. Once you create F-Secure account and subscribe to sync feature, your passwords can be accessed on your smartphone. F-Secure Key mobile app. is available FREE on Google Play Store.

F-Secure Key can also auto-fill your passwords when you open websites.

(2) AVG Vault

It is a mobile app which you can install on your Android/iOS phone to store passwords. To use AVG Vault, a 4-6 digit PIN is required which acts as a master password. Once you have created this PIN, it is used to encrypt your data and sync the encrypted backup to either Dropbox or Google Drive.

One cool feature of AVG Vault is to automatically capture face from front camera if repetitive failed attempts are made to login. This image is mailed to the registered email ID.

 

Both F-Secure and AVG Vault are trusted names in the area of data security.

Tags: , ,

Security | Technology

CONSTANT vs. READONLY in C#

by Rohit 29. March 2014 23:30

 CONSTANT

 

  1. CONST keyword is used to represent a CONSTANT. It is defined at compile-time and cannot be changed at run-time.
  2. Constants are declared as a field and the value must be initialized as they are declared:

 

Public const decimal BonusPercent = 5.25;

 

 

 BonusPercent cannot change in the application and any attempt to change the value raises compiler error.

 

  1. Constants can only be defined as primitive value types like int, double, float etc. Reference types such as a class or a structure cannot be set as Constant.
  2. Constants are by default static in nature, hence you cannot use static keyword with a constant.
  3. Access modifiers like public, private, protected, internal or protected internal can be used with constants.

 

When to use Constants?

 

 Use the const when you are sure that the field value will not be changed throughout the application.

 

 READONLY

 

A readonly, like a constant, represents a value that cannot be changed. However, the difference is that readonly is initialized at run-time. It can be initialized within a non-static constructor or can be initialized as they are declared.

 

In the below code I am trying to initialize the value within a static method:

 

 

You can see above that it is giving an error. Now, as I said before, let us try to initialize it within the default non-static constructor:

 

 

  1. Like constant, readonly is not static by default. You can specify static keyword with readonly.
  2. You can apply readonly to a value-type as well as reference-type.
  3. Once the value is assigned to a readonly at run-time, it cannot be changed again.

 

When to use readonly?

 

If the initial value is to be assigned at run-time based on some parameters and conditions, you can make use of readonly. Once the value is assigned at run-time, it cannot be changed further throughout the program.

 

An example of instance-level initialization:

 

public static readonly Bonus QuarterlyBonus = new Bonus(6.25);

 

 

Tags: ,

.NET | C#

Resolving "Specified cast is not valid" error while seeking a row from DataTable.

by Rohit 22. December 2013 19:24

In a situation I had to create a Data Table manually and add columns and rows to it. Later I wanted to search for a row in this Data Table using LINQ. As soon as LINQ code was fired I got this error: "Specified cast is not valid". Below I am sharing a sample code to simulate this problem and will tell you how to get rid of this error in this particular situation I mentioned above.

Sample Code:

public partial class _Default : System.Web.UI.Page
    {
        DataTable dt = new DataTable();

        protected void Page_Load(object sender, EventArgs e)
        {

            dt.Columns.Add("RowId");
            dt.Columns.Add("Amount");

            DataRow row = dt.NewRow();
            row[0] = 1;
            row[1] = 2000;

            dt.Rows.Add(row);

            GetRecord(1);
        }

        protected void GetRecord(int RowId)
        {
            var results = from row in dt.AsEnumerable()
            where row.Field<int>("RowId") == RowId
            select row;

            string FetchedRowId = results.ToArray()[0].ToString();
        }
    }



If you execute this code, you will get this error:




The root of this error lies during the creation of columns for the Data Table. Do you notice these lines:

dt.Columns.Add("RowId");
dt.Columns.Add("Amount");


Here if you don't specify the Type of column, the default type considered is 'string'. Mentioning the default type of each column solves this issue:

dt.Columns.Add("RowId", typeof(int));
dt.Columns.Add("Amount", typeof(int));

Tags: , , ,

.NET | ASP.NET | C#

About Rohit Prakash

Software Craftsman @ Fortune 100 Company. Technical Reviewer of few programming books.

A Single, Writer, Reader and Adventurist.

You can reach me at:

rohit [at] irohitable.com

-----------------------------------------

LinkedIn:

in.linkedin.com/in/rohitpkhare

Twitter:

@BuzzRohit

-----------------------------------------

Month List

Protected by Copyscape Web Plagiarism Software