Esempio n. 1
0
 /// <summary>
 /// Create an SHA512 hash of a file.
 /// This 128 character hash is for file data integrity checks (e.g. a file contents is unchanged).
 /// </summary>
 /// <param name="fileName">The full path to a file to get the hash.</param>
 /// <returns>The 128 character hex SHA512 Hash.</returns>
 public static Primitive SHA512HashFile(Primitive fileName)
 {
     if (!System.IO.File.Exists(fileName))
     {
         Utilities.OnFileError(Utilities.GetCurrentMethod(), fileName);
         return("");
     }
     return(StringEncryption.CalculateSHA512HashFile(fileName));
 }
Esempio n. 2
0
 /// <summary>
 /// Create a SHA2-512 hash of a text input.
 /// This 128 character hash is recommended for the most secure password encryption.
 /// </summary>
 /// <param name="password">A text to create a hash (often a password).</param>
 /// <returns>The 128 character hex SHA512 Hash.</returns>
 public static Primitive SHA512Hash(Primitive password)
 {
     return(StringEncryption.CalculateSHA512Hash(password));
 }
Esempio n. 3
0
 /// <summary>
 /// Decrypt an AES encrypted cypher (previously encrypted) using a password key.
 /// </summary>
 /// <param name="cypher">The encrypted text (cypher).</param>
 /// <param name="password">The password key for the encryption.</param>
 /// <returns>The original unencrypted text or "" if password and cypher don't match.</returns>
 public static Primitive AESDecrypt(Primitive cypher, Primitive password)
 {
     return(StringEncryption.DecryptString(cypher, password));
 }
Esempio n. 4
0
 /// <summary>
 /// Create an MD5 hash of a text input (http://wikipedia.org/wiki/MD5).
 /// This 32 character hash is recommended where a general or shorter hash is required (password or data integrity).
 /// </summary>
 /// <param name="text">A text or password to create a hash.</param>
 /// <returns>The 32 character hex MD5 Hash.</returns>
 public static Primitive MD5Hash(Primitive text)
 {
     return(StringEncryption.CalculateMD5Hash(text));
 }
Esempio n. 5
0
 /// <summary>
 /// Encrypt some text using AES encryption and a password key.
 /// The encrypted text can be saved to a file.
 /// Note that if you forget the password there is NO WAY to decrypt!
 /// </summary>
 /// <param name="source">The text to encrypt.</param>
 /// <param name="password">The password key for the encryption.</param>
 /// <returns>The encrypted text (cypher).</returns>
 public static Primitive AESEncrypt(Primitive source, Primitive password)
 {
     return(StringEncryption.EncryptString(source, password));
 }