Skip to content
Browse files

[feature] Crypto: added sha512 related functions

  • Loading branch information...
1 parent 8c437b8 commit 346b780a4dde6fe1f4101c1c5ff9e43e92685c83 @Aqua-Ye Aqua-Ye committed Jan 3, 2013
Showing with 31 additions and 0 deletions.
  1. +31 −0 lib/stdlib/crypto/crypto.opa
View
31 lib/stdlib/crypto/crypto.opa
@@ -128,6 +128,14 @@ Crypto = {{
sha256(key, data) = digest("sha256", key, data)
/**
+ * Calculates the HMAC-SHA512 digest of [data] with the secret [key].
+ * @param key is a secret key
+ * @param data is a message
+ * @return the calculated digest
+ */
+ sha512(key, data) = digest("sha512", key, data)
+
+ /**
* Calculates the HMAC-SHA1 digest of [data] with the secret [key].
* @param key is a secret key
* @param data is a message
@@ -181,6 +189,13 @@ Crypto = {{
sha256(data) = digest("sha256", data)
/**
+ * Calculates the SHA512 digest of [data].
+ * @param data is a message
+ * @return the calculated digest
+ */
+ sha512(data) = digest("sha512", data)
+
+ /**
* Calculates the HMAC-RIPEM160 digest of [data].
* @param data is a message
* @return the calculated digest
@@ -228,6 +243,13 @@ Crypto = {{
sha256(data, length) = salt(data, length, Hash.sha256)
/**
+ * Returns a salted and sha512 hashed binary data from [data]
+ * @param data The data to salt and hash
+ * @param length The length of the random salt
+ */
+ sha512(data, length) = salt(data, length, Hash.sha512)
+
+ /**
* Returns a salted and ripemd160 hashed binary data from [data]
* @param data The data to salt and hash
* @param length The length of the random salt
@@ -269,6 +291,15 @@ Crypto = {{
check_sha256(data, salted) = check(data, salted, Hash.sha256)
/**
+ * Checks if the given [data] matches with the [salted] data, using the sha512
+ * hash algorithm.
+ * @param data The data to check
+ * @param salted The salted data used for comparison.
+ * @return A boolean that indicates if [data] matches with the [salted] data
+ */
+ check_sha512(data, salted) = check(data, salted, Hash.sha512)
+
+ /**
* Checks if the given [data] matches with the [salted] data, using the ripemd160
* hash algorithm.
* @param data The data to check

0 comments on commit 346b780

Please sign in to comment.
Something went wrong with that request. Please try again.