File Encryption using Rinjdael with Public and Private Key

The below is an example of how to encrypt and decrypt files using rinjdael with public and private keys for added security.

Step 1:-

First we need 4 Folders and 1 class:

Folder 1: “keys”

Folder 2: “UploadedFiles”

Folder 3: “EncryptedFiles”

Folder 4: “DecryptedFiles”

Class: “FileEncryption.cs”

Continue reading

JavaScript match vs trim

Both the match and the trim can be used as a substitute to string.contains() since JavaScript does not contain the property contains, however they work in different ways:

Match

docomunet.getElementById(‘myId’).textContent.match(‘stringToLookFor’);   // FireFox:  looks for the content ‘stringToLookFor’ in ‘myId’ text and returns true or false

docomunet.getElementById(‘myId’).innerText.match(‘stringToLookFor’);   // Chrome/IE:  looks for the content ‘stringToLookFor’ in ‘myId’ text and returns true or false

Trim

docomunet.getElementById(‘myId’).textContent.trim(‘stringToLookFor’);   // FireFox:  trims the text in myId to ‘stringToLookFor’ and is returned as string /var

docomunet.getElementById(‘myId’).innerText.trim(‘stringToLookFor’);   // Chrome/IE:   trims the text in myId to ‘stringToLookFor’ and is returned as string /var

Continue reading

JavaScript innerText property for Firefox (textContent)

The JavaScript commonly used innerText property functions well in chrome and internet explorer, however in firefox it has a different naming property called textContent:

document.getElementById(‘sample’).innerText = ‘NOT for firefox’;     //Chrome/IE

document.getElementById(‘sample’).textContent= ‘FOR firefox’;  //Firefox

Resolve URL paths

When using MasterPages, Cascading Style Sheets (CSS) and JavaScript files it is quite hard to keep track of all URL paths. Rather than changing the path for each page when referencing the CSS file or any other file which is located in different paths, the ResolveURL can be used. Below are quick examples on how each can be used:

CSS:

<link href=”<%= ResolveUrl(“~/”) %>cssFolder/myStyle.css” rel=”stylesheet” type=”text/css” />

style on html / aspx page:

<div style="background:url('<%= ResolveUrl("~/myImages/myFavImage.jpg") %>') repeat;"> </div>

JavaScript:

<script type=”text/javascript” src=”<%= ResolveUrl(“~/”) %>js/jquery.min.js”></script>

Dynamic URL using jQuery FancyBox:

<a href=”#” onclick=”$.fancybox({‘href’ : ‘<%= ResolveUrl(“~/”) %>myFolder/myPage.html’,’type’:’iframe’,’width’: 900,’height’: 500});return false;”>My Page</a>