DrUalcman-Cipher 1.2.9

dotnet add package DrUalcman-Cipher --version 1.2.9                
NuGet\Install-Package DrUalcman-Cipher -Version 1.2.9                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DrUalcman-Cipher" Version="1.2.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DrUalcman-Cipher --version 1.2.9                
#r "nuget: DrUalcman-Cipher, 1.2.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DrUalcman-Cipher as a Cake Addin
#addin nuget:?package=DrUalcman-Cipher&version=1.2.9

// Install DrUalcman-Cipher as a Cake Tool
#tool nuget:?package=DrUalcman-Cipher&version=1.2.9                

Cipher

Text encryption with secret and key. MD5 can be used in Blazor WebAssemby aplications. All encriptions can be used in Blazoe WebAssembly applications.

Namespaces

Cipher Cipher.Hash Cipher.Tokens Cipher.Hexagesimal

Constructors

Secret()
Secret(byte key)
Secret(string secret)
Secret(string secret, byte key)

Methods

  1. Not Async 1.1 Encript(string word) 1.2 Decript(string word) 1.3 Verify(string secret) 1.4 Verify(byte key) 1.5 Verify(string secret, byte key) 1.6 Verify(string text, string encode)
  2. Async 2.1 EncriptAsync(string word) 2.2 DecriptAsync(string word) 2.3 VerifyAsync(string secret) 2.4 VerifyAsync(byte key) 2.5 VerifyAsync(string secret, byte key) 2.6 VerifyAsync(string text, string encode)

Static Methods

Cipher.Hash

1 Base64 1.1 Not Async 1.1.1 Base64Encode(string data) 1.1.2 Base64Encode(byte[] data) 1.1.3 Base64Decode(string data) 1.1.4 Base64Decode(byte[] data) 1.1.5 Base64UrlEncode(string data) 1.1.6 Base64UrlEncode(byte[] data) 1.1.7 Base64UrlDecode(string data) 1.2 Async 1.2.1 Base64EncodeAsync(string data) 1.2.2 Base64EncodeAsync(byte[] data) 1.2.3 Base64DecodeAsync(string data) 1.2.4 Base64DecodeAsync(byte[] data) 1.2.5 Base64UrlEncodeAsync(string data) 1.2.6 Base64UrlEncodeAsync(byte[] data) 1.2.7 Base64UrlDecodeAsync(string data) 2 MD5 2.1 Not Async 2.1.1 ComputeHash(string message) 2.2 Async 2.2.1 ComputeHashAsync(string message)

Cipher.Tokens

1 Not Async 1.1 CreateToken(int expireDays = 7) 1.2 CreateToken(Dictionary<string, object> dataload) 1.3 CreateToken(Dictionary<string, object> dataload, string cipherKey) 1.4 CreateToken(DateTime expires, IEnumerable<Claim> claims = null, string issuer = null, string audience = null, string[] roles = null) 1.5 CreateToken(string cipherKey, DateTime expires, IEnumerable<Claim> claims = null, string issuer = null, string audience = null, string[] roles = null) 1.6 VerifySignature(string token) 1.7 VerifySignature(string token, string cipherKey) 1.8 TryGetPayloadToken(string token, out Dictionary<string, object> payload) 1.9 TryGetPayloadToken(string token, string cipherKey, out Dictionary<string, object> payload) 2 Async 2.1 CreateTokenAsync(int expireDays = 7) 2.2 CreateTokenAsync(Dictionary<string, object> dataload) 2.3 CreateTokenAsync(Dictionary<string, object> dataload, string cipherKey) 2.4 CreateTokenAsync(DateTime expires, IEnumerable<Claim> claims = null, string issuer = null, string audience = null, string[] roles = null) 2.5 CreateTokenAsync(string cipherKey, DateTime expires, IEnumerable<Claim> claims = null, string issuer = null, string audience = null, string[] roles = null) 2.6 VerifySignatureAsync(string token) 2.7 VerifySignatureAsync(string token, string cipherKey) 2.8 TryGetPayloadTokenAsync(string token, out Dictionary<string, object> payload) 2.9 TryGetPayloadTokenAsync(string token, string cipherKey, out Dictionary<string, object> payload)

Cipher.Helpers

1 Hexagesimal 1.1 ToHex(int number) 1.2 ToInt(string myHex)

How to use

Secret secret = new Secret();
string code = await secret.EncriptAsync("Hello word");
Console.WriteLine(code );
string decode = await secret.DecriptAsync(code);
Console.WriteLine(decode);

Hash to MD5

Cipher.Hash.MD5 md5 = new  Cipher.Hash.MD5();
string encrypted = md5.ComputeHash("Hello Word");
Console.WriteLine(emcrypted);

Hash to Base64

string encrypted = Cipher.Hash.Base64.Base64Encode("Hello Word");
Console.WriteLine(emcrypted);
Console.WriteLine(Cipher.Hash.Base64.Base64Decode(emcrypted));

Create JWT Tokens

Normal Token

string token = Cipher.Tokens.JWT.CreateToken();
Console.WriteLine($"Token : {token1}");
Console.WriteLine($"verifica token : {Cipher.Tokens.JWT.VerifySignature(token1)}");

Secure Token

Dictionary<string, object> payload = new Dictionary<string, object>();
payload.Add("exp", new DateTimeOffset(DateTime.Now.AddDays(1)).ToUnixTimeSeconds());
string token2 = Cipher.Tokens.JWT.CreateToken(payload, "PRIVATE KEY");
Console.WriteLine($"Token 2: {token2}");
Console.WriteLine($"verifica token 2: {Cipher.Tokens.JWT.VerifySignature(token2)}");
Console.WriteLine($"verifica seguro token 2: {Cipher.Tokens.JWT.VerifySignature(token2, "PRIVATE KEY")}");
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.9 524 6/16/2021
1.2.8 395 5/30/2021
1.1.7 357 4/10/2021
1.1.6 331 3/31/2021
1.1.5 397 3/28/2021
1.0.4 385 3/27/2021
1.0.3 310 3/26/2021
1.0.2 322 3/25/2021

Change file aligment to 512