Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

TechNobre/PowerUtils.Security

PowerUtils.Security

⚠️ DEPRECATED

This package has been discontinued because it never evolved, and the current code does not justify its continuation. .NET has evolved significantly, and most of the features provided by this library are now built into the framework with better security and performance.

Logo

Helpers, extensions and utilities to work with security

Support to

  • .NET 3.1 or more
  • .NET Framework 4.6.2 or more
  • .NET Standard 2.0 or more

How to use

Install NuGet package

This package is available through Nuget Packages: https://www.nuget.org/packages/PowerUtils.Security

Nuget

Install-Package PowerUtils.Security

.NET CLI

dotnet add package PowerUtils.Security

HashExtensions

string.ToMD5();

Convert a text to hash MD5

// result = "dc483e80a7a0bd9ef71d8cf973673924"
var result = "a123456".ToMD5();

string.ToSHA1();

Convert a text to hash SHA1

// result = "895b317c76b8e504c2fb32dbb4420178f60ce321"
var result = "a123456".ToSHA1();

string.ToSHA256();

Convert a text to hash SHA256

// result = "20f645c703944a0027acf6fad92ec465247842450605c5406b50676ff0dcd5ea"
var result = "a123456".ToSHA256();

string.ToSHA384();

Convert a text to hash SHA384

// result = "fec1bb0e04ed484a4e5e37e585c9d15f863db7e7f5585e047a1be80e269d50abb177e61c264f6c0443e4d8e26b235d8e"
var result = "a123456".ToSHA384();

string.ToSHA512();

Convert a text to hash SHA512

// result = "410752b9f6fef035ccb2b469bcc473d7d43e93a108332bc1eb3208412d599bb4478eea687c69f962d7670410b06deaeac77578452f7c2454f3100d017a802b7e"
var result = "a123456".ToSHA512();

EncodeExtensions

string.ToBase64();

Encode text to base64

// result = "SGVsbG9Xb3JsZA=="
var result = "HelloWorld".ToBase64();

string.FromBase64();

Decode base64 to original text

// result = "HelloWorld"
var result = "SGVsbG9Xb3JsZA==".FromBase64();

EncryptExtensions

string.Encrypt(passPhrase);

Encrypt text based in passPhrase

var passPhrase = "fssdf4523543dfd";

// result = "zhwH2dmpqUebzikGD4UHnw=="
var result = "HelloWorld".Encrypt();

string.Decrypt(passPhrase);

Decrypt cipher text

var passPhrase = "fssdf4523543dfd";

// result = "HelloWorld"
var result = "zhwH2dmpqUebzikGD4UHnw==".Decrypt();

AnonymizationExtensions

string.Anonymize();

Anonymize sensitive information

// result = "N****e"
var result = "Nelson Nobre".Anonymize();

UtilsAuth

UtilsAuth.ToBasicAuth(username, password);

Encode username and password to basic authentication (btoa) [Beautiful to Awful]

var username = "jon";
var password = "a123456";

// result = "am9uOmExMjM0NTY="
var result = UtilsAuth.ToBasicAuth(username, password);

string.FromBasicAuth();

Decode from basic authentication (atob) [Awful to Beautiful]

// username = "jon" | password = "a123456"
var result = "am9uOmExMjM0NTY=".FromBasicAuth();

Contribution

If you have any questions, comments, or suggestions, please open an issue or create a pull request

About

Helpers, extensions and utilities to work with security

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages