|
|
Runtime Type : Types : CryptoUtil
From $1
A utility class that implements various cryptographic functions such as hashing and random number generation.
Back to Runtime Types
Inherits From
root→Object→CryptoUtil
Function Detail
RSAPrivateDecrypt
Computes
Syntax
RSAPrivateDecrypt([in] string cipherText, [in] string privateKey, [in] string privateKeyPassword, [out] string clearText, [out] int errorCode)
Parameters
- cipherText
- description
- privateKey
- description
- privateKeyPassword
- description
- clearText
- description
- errorCode
- If the errorCode returned is greater than 0, the function completed successfully. If the errorCode is less than zero, the function failed. You can pass this errorCode to getRSAErrorString to get an error string with information about the errorCode.
RSAPublicEncrypt
Computes
Syntax
RSQPublicEncrypt([in] string clearText, [in] string publicKey, [out] string cipherText, [out] int errorCode)
Parameters
- clearText
- description
- publicKey
- description
- cipherText
- description
- errorCode
- If the errorCode returned is greater than 0, the function completed successfully. If the errorCode is less than zero, the function failed. You can pass this errorCode to getRSAErrorString to get an error string with information about the errorCode.
RSAVerifyPrivateKey
Computes
Syntax
RSAVerifyPrivateKey([in] string privateKey, [in] string privateKeyPassword, [out] boolean isValid)
Parameters
- privateKey
- description
- privateKeyPassword
- description
- isValid
- description
changeRSAPrivateKeyPassword
Computes
Syntax
changesRSAPrivateKeyPassword([in] string privateKey, [in] string oldPassword, [in] string newPassword, [out] string newPrivateKey, [out] int errorCode)
Parameters
- privateKey
- description
- oldPassword
- description
- newPassword
- description
- newPrivateKey
- description
- errorCode
- If the errorCode returned is greater than 0, the function completed successfully. If the errorCode is less than zero, the function failed. You can pass this errorCode to getRSAErrorString to get an error string with information about the errorCode.
computeDHSecret
Computes
Syntax
computeDHSecret([in] int generator, [in] string prime, [in] string privateKey, [in] string publicKey, [in] string receivedPublicKey, [out] string secret)
Parameters
- generator
- description
- prime
- description
- privateKey
- The private key.
- publicKey
- The public key.
- receivedPublicKey
- description
- secret
- description
computeHMAC
Computes the HMAC (keyed-Hash Message Authentication Code).
Syntax
computeHMAC([in] string digest, [in] Data data, [in] string key, [in] boolean base64, [out] string hashHMAC)
Parameters
- digest
- A string containing the name of the digest (hash algorithm). For example, several of the more common digests include "SHA1" and "MD5".
- data
- The data to be hashed.
- key
- The private key.
- base64
- A flag indicating whether to Base64-encode the result. A value of true indicates that the result is Base64-encoded. Otherwise, the result is encoded with lowercase hexadecimal.
- hashHMAC
- Reference to a string that receives the resulting HMAC. The result HMAC is empty if the specified digest is unsupported.
computeHash
Computes a hash.
Syntax
computeHash([in] string digest, [in] Data data, [in] boolean base64, [out] string hash)
Parameters
- digest
- A string containing the name of the digest (hash algorithm). For example, several of the more common digests include "SHA1" and "MD5".
- data
- The data to be hashed.
- base64
- A flag indicating whether to Base64-encode the result. A value of true indicates that the result is Base64-encoded. Otherwise, the result is encoded with lowercase hexadecimal.
- hash
- Reference to a string that receives the resulting hash. The resulting hash is empty if the specified digest is unsupported.
decrypt
Decrypts a Base64-encoded encrypted string into clear text.
Syntax
decrypt([in] string cipherName, [in] string key, [in] string iv, [in] string cipherText, [out] clearText, [out] int errorCode, [out] string errorString)
Parameters
cipherName
The name of the cipher (or algorithm) to use for decryption. key
The key to use for decryption.
iv
The initialization vector to use for decryption.
cipherText
The Base64-encoded encrypted string to be decrypted.
clearText
The decrypted clear text.
errorCode
An integer indicating the success or failure of the encryption. This can be one of the following values:
- -32—The cipher was not found. This error occurs when the cipher specified by the cipherName parameter does not match a supported cipher.
- -31—The key was empty.
- -30—The length of the initialization vector was invalid.
- -28—The cipher text was empty.
- -27—The cipher could not be initialized.
- -26—Decryption failure.
- 1—Success
errorString
A human-readable string describing the most recent error that occured.
decrypt_SuppliedIV
Decrypts a Base64-encoded encrypted string into clear text where the IV data is contained at the beginning of the Base64-encoded string.
Syntax
decrypt_SuppliedIV([in] string cipherName, [in] string key, [in] bool containsIV, [in] string cipherText, [out] clearText, [out] int errorCode, [out] string errorString)
Parameters
cipherName
The name of the cipher (or algorithm) to use for decryption. key
The key to use for decryption.
containsIV
If set to true, the IV bytes will be extracted from the beginning of cipherText buffer after it is Base64 decoded. The length of the IV bytes will be determined by the cipher specified by cipherName. If false, then no IV will be used.
cipherText
The Base64-encoded encrypted string to be decrypted that contains the IV data at it's beginning.
clearText
The decrypted clear text.
errorCode
An integer indicating the success or failure of the encryption. This can be one of the following values:
- -32—The cipher was not found. This error occurs when the cipher specified by the cipherName parameter does not match a supported cipher.
- -31—The key was empty.
- -30—The length of the initialization vector was invalid.
- -28—The cipher text was empty.
- -27—The cipher could not be initialized.
- -26—Decryption failure.
- 1—Success
errorString
A human-readable string describing the most recent error that occured.
encrypt
Encrypts a string into a Base64-encoded string.
Syntax
encrypt([in] cipherName, [in] string key, [in] string iv, [in] string clearText, [out] string cipherText, [out] int errorCode, [out] string errorString)
Parameters
cipherName
The name of the cipher (or algorithm) to use for encryption. key
The key to use for encryption. iv
The initialization vector to use for encryption. clearText
The clear text to be encrypted. cipherText
The encrypted string, which is Base64-encoded before it is returned. errorCode
An integer indicating the success or failure of the encryption. This can be one of the following values:
- -32—The cipher was not found. This error occurs when the cipher specified by the cipherName parameter does not match a supported cipher.
- -31—The key was empty.
- -30—The length of the initialization vector was invalid.
- -29—The clear text was empty.
- -27—The cipher could not be initialized.
- -25—Encryption failure.
- 1—Success
errorString
A human-readable string describing the most recent error that occured.
enumCiphers
Enumerates the ciphers (algorithms) supported by CryptoUtil.
Syntax
enumCiphers([out] Collection(string) ciphers)
Parameters
ciphers
Reference to a collection that receives the collection of strings identifying the ciphers supported by CryptoUtil.
enumDigests
Enumerates the digests (hashing algorithms) supported by CryptoUtil. Each of the digests returned by enumDigests can be passed to either computeHMAC or computeHash. The digests currently supported by CryptoUtil include:
- DSA
- DSA-SHA
- DSA-SHA1
- DSA-SHA1-old
- dsaEncryption
- dsaWithSHA1
- dsaWithSHA1ripemd160WithRSA
- DSS1
- ecdsa-with-SHA1
- MD2
- md2WithRSAEncryption
- MD4
- md4WithRSAEncryption
- MD5
- md5WithRSAEncryption
- ripemd
- RIPEMD160
- rmd160
- RSA-MD2
- RSA-MD4
- RSA-MD5
- RSA-RIPEMD160
- RSA-SHA
- RSA-SHA1
- RSA-SHA1-2
- RSA-SHA224
- RSA-SHA256
- RSA-SHA384
- RSA-SHA512
- SHA
- SHA1
- sha1WithRSAEncryption
- SHA224
- sha224WithRSAEncryption
- SHA256
- sha256WithRSAEncryption
- SHA384
- sha384WithRSAEncryption
- SHA512
- sha512WithRSAEncryption
- shaWithRSAEncryption
- ssl2-md5
- ssl3-md5
- ssl3-sha1
Syntax
enumDigests([out] Collection(string) digests)
Parameters
- digests
- Reference to a collection that receives the collection of strings identifying the digests supported by CryptoUtil.
generateDHKeys
Generates
Syntax
generateDHKeys([in] int generator, [in] string prime, [out] string privateKey [out] string publicKey)
Parameters
- generator
- description
- prime
- description
- privateKey
- description
- publicKey
- description
generateDHPrime
Generates
Syntax
generateDHPrime([in] int bitSize, [in] int generator [out] string prime)
Parameters
- bitSize
- description
prime - generator
- description
- description
getRSAErrorString
Returns a string with infomation about the errorCode specified.
If the errorCode returned by another RSA function is greater than 0, the function completed successfully. If the errorCode is less than zero, the function failed.
Syntax
getRSAErrorString([in] int errorCode, [out] string errorString)
Parameters
- errorCode
- The int errorCode returned by the other RSA function calls.
- errorString
- A string that will give you information about the specified errorCode.
getRSAKeyPair
Generates
Syntax
getRSAKeyPair([in] uint keySize, [in] string privateKeyPassword, [out] string privateKey, [out] string publicKey, [out] int errorCode)
Parameters
- keySize
- description
- privateKeyPassword
- description
- privateKey
- description
- publicKey
- description
- errorCode
- If the errorCode returned is greater than 0, the function completed successfully. If the errorCode is less than zero, the function failed. You can pass this errorCode to [getRSAErrorString] to get an error string with information about the errorCode.
getRandomAlnum
Generates a cryptographically strong sequence of alphanumeric characters.
Syntax
getRandomAlnum([in] int length, [out] string random)
Parameters
- length
- A ulong that specifies the length of the random sequence.
- random
- Reference to a string that receives the random sequence of alphanumeric characters.
getRandomBytes
Generates a cryptographically strong sequence of random bytes. The range for random bytes includes ASCII characters between 1 and 255.
Syntax
getRandomBytes([in] int length, [out] string random)
Parameters
- length
- A ulong that specifies the length of the random sequence.
- random
- Reference to a string that receives the random sequence of bytes.
getRandomDouble
Generates a cryptographically strong random double.
Syntax
getRandomDouble([out] double random)
Parameters
- random
- Reference to a double that receives the resulting random value.
getRandomDoubleRange
Generates a cryptographically strong random double within a specified range. The algorithm does not exclude the lower and upper limits. Therefore, a range with a minimum value of 0.1 and a maximum of 3.1415927 includes 0.1, 3.1415927, and everything in between.
Syntax
getRandomDoubleRange([in] double min, [in] double max, [out] double random)
Parameters
- min
- The minimum value. Must be non-negative.
- max
- The maximum value. Must be non-negative and greater than min.
- random
- Reference to a double that receives the resulting random value.
getRandomLong
Generates a cryptographically strong random ulong.
Syntax
getRandomLong([out] ulong random)
Parameters
- random
- Reference to a ulong that receives the random value.
getRandomLongRange
Generates a cryptographically strong random ulong within a specified range. The algorithm does not exclude the lower and upper limits. Therefore, a range with a minimum value of 0 and a maximum of 1024 includes both 0, 1024, and everything in between.
Syntax
getRandomLongRange([in] ulong min, [in] ulong max, [out] ulong random)
Parameters
- min
- The minimum value.
- max
- The maximum value. Must be greater than min.
- random
- Reference to a ulong that receives the random value.
getRandomString
Generates a cryptographically strong sequence of printable characters. The range of printable characters includes ASCII characters between 33 and 126.
Syntax
getRandomString([in] int length, [out] string random)
Parameters
- length
- A ulong that specifies the length of the random sequence.
- random
- Reference to a string that receives the random sequence of printable characters.
|