-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ICryptographicCenter and ISerializationCenter interfaces
- Loading branch information
1 parent
9a812f0
commit 29af6eb
Showing
14 changed files
with
414 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
namespace Upsilon.Apps.PassKey.Core.Interfaces | ||
{ | ||
/// <summary> | ||
/// Represent a cryptographic center. | ||
/// </summary> | ||
public interface ICryptographicCenter | ||
{ | ||
/// <summary> | ||
/// Returs a fast string hash of the given string. | ||
/// </summary> | ||
/// <param name="source">The string to hash.</param> | ||
/// <returns>The hash.</returns> | ||
public string GetHash(string source); | ||
|
||
/// <summary> | ||
/// Returs a slow string hash of the given string. | ||
/// </summary> | ||
/// <param name="source">The string to hash.</param> | ||
/// <returns>The hash.</returns> | ||
string GetSlowHash(string source); | ||
|
||
/// <summary> | ||
/// The fixed length of the hash. | ||
/// </summary> | ||
int HashLength { get; } | ||
|
||
/// <summary> | ||
/// Sign a string. | ||
/// </summary> | ||
/// <param name="source">The string to sign. The method will modify the string to add the signature.</param> | ||
void Sign(ref string source); | ||
|
||
/// <summary> | ||
/// check the signature of a given string. | ||
/// </summary> | ||
/// <param name="source">The string to sign. The method will modify the string to remove the signature.</param> | ||
/// <returns>True if the signature is good, False else.</returns> | ||
bool CheckSign(ref string source); | ||
|
||
/// <summary> | ||
/// Encrypt a string with a set of passekeys in an onion structure. | ||
/// </summary> | ||
/// <param name="source">The string to encrypt.</param> | ||
/// <param name="passwords">The set of passkeys.</param> | ||
/// <returns>The encrypted string.</returns> | ||
string Encrypt(string source, string[] passwords); | ||
|
||
/// <summary> | ||
/// Decrypt a string with a set of passekeys in an onion structure. | ||
/// </summary> | ||
/// <param name="source">The string to decrypt.</param> | ||
/// <param name="passwords">The set of passkeys.</param> | ||
/// <returns>The decrypted string.</returns> | ||
string Decrypt(string source, string[] passwords); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Upsilon.Apps.PassKey.Core.Interfaces | ||
{ | ||
/// <summary> | ||
/// Represent a serialization center. | ||
/// </summary> | ||
public interface ISerializationCenter | ||
{ | ||
/// <summary> | ||
/// Serialize the given object to a string. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the object.</typeparam> | ||
/// <param name="toSerialize">The object to serialize.</param> | ||
/// <returns>The serialised string.</returns> | ||
string Serialize<T>(T toSerialize) where T : notnull; | ||
|
||
/// <summary> | ||
/// Deserialize the given string to the given type object. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the object.</typeparam> | ||
/// <param name="toDeserialize">The serialised string.</param> | ||
/// <returns>The deserialized object.</returns> | ||
T Deserialize<T>(string toDeserialize) where T : notnull; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.