Skip to content

Instantly share code, notes, and snippets.

View gayancc's full-sized avatar
🎯
Focusing

Gayan Ranasinghe gayancc

🎯
Focusing
View GitHub Profile
public virtual string CreatePasswordHash(string password, string saltkey, string passwordFormat = "SHA1")
{
if (String.IsNullOrEmpty(passwordFormat))
passwordFormat = "SHA1";
string saltAndPassword = String.Concat(password, saltkey);
var algorithm = HashAlgorithm.Create(passwordFormat);
if (algorithm == null)
throw new ArgumentException("Unrecognized hash name", "hashName");
var hashByteArray = algorithm.ComputeHash(Encoding.UTF8.GetBytes(saltAndPassword));
public string CreateSaltKey(int size)
{
var rng = new RNGCryptoServiceProvider();
var buff = new byte[size];
rng.GetBytes(buff);
return Convert.ToBase64String(buff);
}
@gayancc
gayancc / importDefinition.cs
Created October 8, 2015 10:49
Create import Definition ExactTarget
public string[] CreateImportDefinition(string fileName, string destinationKey, int destinationId)
{
var key = Guid.NewGuid().ToString();
var definition = new ExactTargetApi.ImportDefinition
{
Name = key,
CustomerKey = key,
Description = string.Format("This import definition was created through the API. On {0}", DateTime.Now.ToShortDateString()),
AllowErrors = true,
AllowErrorsSpecified = true,
@gayancc
gayancc / clearTextboxes
Created September 17, 2015 06:36
clear text box value util class
private void ClearTextBoxes()
{
Action<Control.ControlCollection> func = null;
func = (controls) =>
{
foreach (Control control in controls)
if (control is TextBox)
(control as TextBox).Clear();
else