Skip to content

Instantly share code, notes, and snippets.

View proteo5's full-sized avatar

Alfredo Pinto Molina proteo5

View GitHub Profile
@proteo5
proteo5 / TableToClassCS.sql
Created September 22, 2022 05:58
Easily create classes on C# and Visual Basic from MS SQL Tables
declare @TableName sysname = 'table_name' -- Replace this with your database table name.
declare @Result varchar(max) = 'public class ' + @TableName + '
{'
select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
(
select
@proteo5
proteo5 / CURPValido.cs
Created June 11, 2020 20:13
Métodos en C# para Validar el CURP
private bool CurpValida(string curp)
{
var re = @"^([A-Z][AEIOUX][A-Z]{2}\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])[HM](?:AS|B[CS]|C[CLMSH]|D[FG]|G[TR]|HG|JC|M[CNS]|N[ETL]|OC|PL|Q[TR]|S[PLR]|T[CSL]|VZ|YN|ZS)[B-DF-HJ-NP-TV-Z]{3}[A-Z\d])(\d)$";
Regex rx = new Regex(re, RegexOptions.Compiled | RegexOptions.IgnoreCase);
var validado = rx.IsMatch(curp);
if (!validado) //Coincide con el formato general?
return false;
//Validar que coincida el dígito verificador
@proteo5
proteo5 / RSAHelper.cs
Created May 13, 2020 19:33
A helper to manage RSA keys and massages
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Xml;
@proteo5
proteo5 / Result.cs
Last active February 11, 2024 07:33
A class to facilitate the communication between layers on C#
namespace Proteo5.HL;
public class Result
{
public Result()
{
this.State = ResultsStates.success;
}
public Result(string state)
@proteo5
proteo5 / TokenHL.cs
Created May 13, 2020 19:26
This helper will simplify the use of JWT on C#
using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
using System.Text;
namespace Proteo5.Utils
{
@proteo5
proteo5 / HashHL.cs
Last active September 22, 2022 06:06
Helper that simplifies the use of hashes on C#
// .NET Core 6 updated
using System;
using System.Security.Cryptography;
using System.Text;
namespace Proteo5.Utils;
public class HashHL
{