Skip to content

Commit

Permalink
Merge pull request #10 from PandaTechAM/development
Browse files Browse the repository at this point in the history
mask class extension
  • Loading branch information
HaikAsatryan authored Jan 23, 2024
2 parents 6f55e12 + fbe5dc0 commit fc35153
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ string maskedEmail = Mask.MaskEmail("[email protected]");
string maskedPhone = Mask.MaskPhoneNumber("1234567890");

// Output: "******7890"
// You can also use the MaskEmail and MaskPhoneNumber methods as extension methods on strings
string maskedEmail = "[email protected]";
string maskedPhone = "1234567890";

string maskedEmail = maskedEmail.MaskEmail();
string maskedPhone = maskedPhone.MaskPhoneNumber();
```

## 1.5. License
Expand Down
8 changes: 4 additions & 4 deletions src/Pandatech.Crypto.Tests/MaskTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MaskTests
[InlineData("[email protected]", "[email protected]")]
public void MaskEmail_ValidEmails_ReturnsMaskedEmail(string input, string expected)
{
var result = Mask.MaskEmail(input);
var result = input.MaskEmail();
Assert.Equal(expected, result);
}

Expand All @@ -22,7 +22,7 @@ public void MaskEmail_ValidEmails_ReturnsMaskedEmail(string input, string expect
[InlineData("notanemail")]
public void MaskEmail_InvalidEmails_ThrowsArgumentException(string input)
{
Assert.Throws<ArgumentException>(() => Mask.MaskEmail(input));
Assert.Throws<ArgumentException>(input.MaskEmail);
}

[Theory]
Expand All @@ -31,7 +31,7 @@ public void MaskEmail_InvalidEmails_ThrowsArgumentException(string input)
[InlineData("12", "12")]
public void MaskPhoneNumber_ValidPhoneNumbers_ReturnsMaskedPhone(string input, string expected)
{
var result = Mask.MaskPhoneNumber(input);
var result = input.MaskPhoneNumber();
Assert.Equal(expected, result);
}

Expand All @@ -40,6 +40,6 @@ public void MaskPhoneNumber_ValidPhoneNumbers_ReturnsMaskedPhone(string input, s
[InlineData("")]
public void MaskPhoneNumber_InvalidPhoneNumbers_ThrowsArgumentException(string input)
{
Assert.Throws<ArgumentException>(() => Mask.MaskPhoneNumber(input));
Assert.Throws<ArgumentException>(input.MaskPhoneNumber);
}
}
4 changes: 2 additions & 2 deletions src/Pandatech.Crypto/Mask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Pandatech.Crypto;

public static class Mask
{
public static string MaskEmail(string email)
public static string MaskEmail(this string email)
{
if (!PandaValidator.IsEmail(email))
{
Expand All @@ -20,7 +20,7 @@ public static string MaskEmail(string email)
return $"{maskedLocalPart}@{domainPart}";
}

public static string MaskPhoneNumber(string phoneNumber)
public static string MaskPhoneNumber(this string phoneNumber)
{
if (string.IsNullOrEmpty(phoneNumber))
{
Expand Down
4 changes: 2 additions & 2 deletions src/Pandatech.Crypto/Pandatech.Crypto.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<Copyright>MIT</Copyright>
<PackageIcon>pandatech.png</PackageIcon>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<Version>2.2.5</Version>
<Version>2.2.6</Version>
<Title>Pandatech.Crypto</Title>
<PackageTags>Pandatech, library, encryption, hash, algorythms, security</PackageTags>
<Description>PandaTech.Crypto is a .NET library simplifying common cryptograhic functions.</Description>
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-pandatech-crypto</RepositoryUrl>
<PackageReleaseNotes>Added Mask class</PackageReleaseNotes>
<PackageReleaseNotes>Mask class extension</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit fc35153

Please sign in to comment.