Juan Garcés

Personal Blog

Connect MySQL with PDO

August 17th, 2014

Connection to MySQL using PDO library.

CREATE TABLE `paciente` (
  `paciente_rut` varchar(12) NOT NULL,
  `paciente_nombre` varchar(100) NOT NULL,
  `paciente_apellidop` varchar(100) NOT NULL,
  `paciente_apellidom` varchar(100) default NULL,
  `paciente_fono` varchar(50) default NULL,
  `paciente_direccion` varchar(255) NOT NULL,
  PRIMARY KEY  (`paciente_rut`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `paciente` VALUES ('11111111-1', 'Pedro', 'Fuentes', 'García', NULL, 'Santiago');
INSERT INTO `paciente` VALUES ('22222222-2', 'Juan', 'Santana', 'Bustos', NULL, 'Santiago');
INSERT INTO `paciente` VALUES ('33333333-3', 'Carolina', 'Soto', 'Barra', NULL, 'Santiago');

Crypt with SHA1

August 9th, 2014

Method to crypt with SHA1

/// 
/// Crypt the string with SHA1
/// 
public static string EncriptarSHA1(string sCadena)
{
	System.Security.Cryptography.SHA1 sha1 = System.Security.Cryptography.SHA1Managed.Create();

	ASCIIEncoding encoding = new ASCIIEncoding();
	byte[] stream = null;
	StringBuilder codificada = new StringBuilder();
	stream = sha1.ComputeHash(encoding.GetBytes(sCadena));

	for (int i = 0; i < stream.Length; i++) codificada.AppendFormat("{0:x2}", stream[i]);
	return codificada.ToString();
}

Welcome

January 1st, 2013

Welcome!

In this blog I will share with you my experiences on different tools that I have worked, as well as developments and personal studies.

All content is free to access and you can be used without restrictions. Check the Terms of Use

Regards

Juan Garcés Bustamante

Juan Garcés

Personal Blog