Module

# Crypto

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Contains hashing methods for use with cryptography.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                    | Parameters                                                                                                                                                                                                                                                             | Returns                                        | Shared                                   |
|---------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|------------------------------------------|
| `AESDecrypt<crypto.aesdecrypt>`                         | publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`                      | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `AESEncrypt<crypto.aesencrypt>`                         | publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`                      | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `BERDecodePrivateKey<crypto.berdecodeprivatekey>`       | privateKey As `String</api/data_types/string>`                                                                                                                                                                                                                         | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `BERDecodePublicKey<crypto.berdecodepublickey>`         | publicKey As `String</api/data_types/string>`                                                                                                                                                                                                                          | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `BlowFishDecrypt<crypto.blowfishdecrypt>`               | publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`                      | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `BlowFishEncrypt<crypto.blowfishencrypt>`               | publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`                      | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `DEREncodePrivateKey<crypto.derencodeprivatekey>`       | privateKey As `String</api/data_types/string>`                                                                                                                                                                                                                         | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `DEREncodePublicKey<crypto.derencodepublickey>`         | publicKey As `String</api/data_types/string>`                                                                                                                                                                                                                          | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `ED25519GenerateKeyPair<crypto.ed25519generatekeypair>` | `ByRef</api/language/byref>` PrivateKey As `String</api/data_types/string>`, `ByRef</api/language/byref>` PublicKey As `String</api/data_types/string>`                                                                                                                | `Boolean</api/data_types/boolean>`             |                                          |
| `ED25519Sign<crypto.ed25519sign>`                       | data As `MemoryBlock</api/language/memoryblock>`                                                                                                                                                                                                                       | privateKey As `String</api/data_types/string>` | `MemoryBlock</api/language/memoryblock>` |
| `ED25519VerifyKey<crypto.ed25519verifykey>`             | Key As `String</api/data_types/string>`                                                                                                                                                                                                                                | `Boolean</api/data_types/boolean>`             |                                          |
| `ED25519VerifySignature<crypto.ed25519verifysignature>` | data As `MemoryBlock</api/language/memoryblock>`, signature As `MemoryBlock</api/language/memoryblock>`, publicKey As `String</api/data_types/string>`                                                                                                                 | `Boolean</api/data_types/boolean>`             |                                          |
| `ES256GenerateKeyPair<crypto.es256generatekeypair>`     | `ByRef</api/language/byref>` PrivateKey As `String</api/data_types/string>`, `ByRef</api/language/byref>` PublicKey As `String</api/data_types/string>`                                                                                                                | `Boolean</api/data_types/boolean>`             |                                          |
| `ES256Sign<crypto.es256sign>`                           | data As `MemoryBlock</api/language/memoryblock>`, privateKey As `String</api/data_types/string>`                                                                                                                                                                       | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `ES256VerifyKey<crypto.es256verifykey>`                 | Key As `String</api/data_types/string>`                                                                                                                                                                                                                                | `Boolean</api/data_types/boolean>`             |                                          |
| `ES256VerifySignature<crypto.es256verifysignature>`     | data As `MemoryBlock</api/language/memoryblock>`, signature As `MemoryBlock</api/language/memoryblock>`, publicKey As `String</api/data_types/string>`                                                                                                                 | `Boolean</api/data_types/boolean>`             |                                          |
| `GenerateRandomBytes<crypto.generaterandombytes>`       | ByteCount As `Integer</api/data_types/integer>`                                                                                                                                                                                                                        | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `Hash<crypto.hash>`                                     | data As `MemoryBlock</api/language/memoryblock>`, hashAlgorithm As `Crypto.HashAlgorithms<crypto.hashalgorithms>`                                                                                                                                                      | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `HMAC<crypto.hmac>`                                     | key As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, hashAlgorithm As `Crypto.HashAlgorithms<crypto.hashalgorithms>`                                                                                                             | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `MD5<crypto.md5>`                                       | data As `MemoryBlock</api/language/memoryblock>`                                                                                                                                                                                                                       | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `PBKDF2<crypto.pbkdf2>`                                 | salt As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, iterations As `Integer</api/data_types/integer>`, desiredHashLength As `Integer</api/data_types/integer>`, hashAlgorithm As `Crypto.HashAlgorithms<crypto.hashalgorithms>` | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `RSADecrypt<crypto.rsadecrypt>`                         | Data As `MemoryBlock</api/language/memoryblock>`, PrivateKey As `String</api/data_types/string>`                                                                                                                                                                       | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `RSAEncrypt<crypto.rsaencrypt>`                         | Data As `MemoryBlock</api/language/memoryblock>`, PublicKey As `String</api/data_types/string>`                                                                                                                                                                        | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `RSAGenerateKeyPair<crypto.rsageneratekeypair>`         | Bits As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` PrivateKey As `String</api/data_types/string>`, `ByRef</api/language/byref>` PublicKey As `String</api/data_types/string>`                                                                    | `Boolean</api/data_types/boolean>`             |                                          |
| `RSASign<crypto.rsasign>`                               | data As `MemoryBlock</api/language/memoryblock>`, privateKey As `String</api/data_types/string>`, mode As `Crypto.RSASignModes<crypto.rsasignmodes>` = `Crypto.RSASignModes.SHA1<crypto.rsasignmodes>`                                                                 | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `RSAVerifyKey<crypto.rsaverifykey>`                     | Key As `String</api/data_types/string>`                                                                                                                                                                                                                                | `Boolean</api/data_types/boolean>`             |                                          |
| `RSAVerifySignature<crypto.rsaverifysignature>`         | data As `MemoryBlock</api/language/memoryblock>`, signature As `MemoryBlock</api/language/memoryblock>`, publicKey As `String</api/data_types/string>`, mode As `Crypto.RSASignModes.SHA1<crypto.rsasignmodes>`                                                        | `Boolean</api/data_types/boolean>`             |                                          |
| `SHA1<crypto.sha1>`                                     | data As `MemoryBlock</api/language/memoryblock>`                                                                                                                                                                                                                       | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `SHA2_256<crypto.sha2_256>`                             | data As `MemoryBlock</api/language/memoryblock>`                                                                                                                                                                                                                       | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `SHA2_512<crypto.sha2_512>`                             | data As `MemoryBlock</api/language/memoryblock>`                                                                                                                                                                                                                       | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `SHA3_256<crypto.sha3_256>`                             | data As `MemoryBlock</api/language/memoryblock>`                                                                                                                                                                                                                       | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `SHA3_512<crypto.sha3_512>`                             | data As `MemoryBlock</api/language/memoryblock>`                                                                                                                                                                                                                       | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `TwoFishDecrypt<crypto.twofishdecrypt>`                 | publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto.BlockModes<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`           | `MemoryBlock</api/language/memoryblock>`       |                                          |
| `TwoFishEncrypt<crypto.twofishencrypt>`                 | publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto.BlockModes<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`           | `MemoryBlock</api/language/memoryblock>`       |                                          |

## Enumerations

<div id="crypto.blockmodes">

<div class="rst-class">

forsearch

</div>

</div>

Crypto.BlockModes

### BlockModes

> The block modes for use with AES, BlowFish and TwoFish encryption and decryption.
>
> | Enum | Description                                                                                                                                                                                                                          |
> |------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
> | CBC  | An initialization vector-based encryption scheme, the mode is secure as a probabilistic encryption scheme, achieving indistinguishability from random bits, assuming a random initialization vector.                                 |
> | ECB  | A blockcipher, the mode enciphers messages that are a multiple of n bits by separately enciphering each n-bit piece.                                                                                                                 |
> | CTR  | A counter-based mode that turns the block cipher into a stream cipher by encrypting a nonce + counter value and XORing it with the data. It is fast, parallelizable, and uses the same operation for both encryption and decryption. |

<div id="crypto.hashalgorithms">

<div class="rst-class">

forsearch

</div>

</div>

Crypto.HashAlgorithms

### HashAlgorithms

> The hash algorithm to use with <span class="title-ref">Crypto</span> functions.
>
> | Enum     | Description                                                                         |
> |----------|-------------------------------------------------------------------------------------|
> | CRC32    | [CRC32](https://en.wikipedia.org/wiki/Cyclic_redundancy_check)                      |
> | MD5      | [MD5 message-digest](https://en.wikipedia.org/wiki/MD5)                             |
> | SHA1     | [SHA1 algorithm (160-bit (20-byte) hash value)](http://en.wikipedia.org/wiki/Sha1)  |
> | SHA256   | [SHA256 algorithm (SHA-2 with 256 bit digest)](http://en.wikipedia.org/wiki/Sha256) |
> | SHA2_256 | [SHA256 algorithm (SHA-2 with 256 bit digest)](http://en.wikipedia.org/wiki/Sha256) |
> | SHA2_512 | [SHA512 algorithm (SHA-2 with 512 bit digest)](http://en.wikipedia.org/wiki/Sha512) |
> | SHA3_256 | [SHA3 algorithm](https://en.wikipedia.org/wiki/SHA-3)                               |
> | SHA3_512 | [SHA3 algorithm](https://en.wikipedia.org/wiki/SHA-3)                               |
> | SHA512   | [SHA512 algorithm (SHA-2 with 512 bit digest)](http://en.wikipedia.org/wiki/Sha512) |

<div id="crypto.rsasignmodes">

<div class="rst-class">

forsearch

</div>

</div>

Crypto.RSASignModes

### RSASignModes

> The sign modes to use with the `RSASign<crypto.rsasign>` and `RSAVerifySignature<crypto.rsaverifysignature>` methods.
>
> | Enum            | Signing Scheme                                                                               |
> |-----------------|----------------------------------------------------------------------------------------------|
> | PKCS1v15_SHA1   | [Public Key Cryptography Standards](https://en.wikipedia.org/wiki/PKCS_1)                    |
> | PKCS1v15_SHA256 | [Public Key Cryptography Standards](https://en.wikipedia.org/wiki/PKCS_1)                    |
> | PKCS1v15_SHA512 | [Public Key Cryptography Standards](https://en.wikipedia.org/wiki/PKCS_1)                    |
> | PSS_SHA1        | [Probabilistic Signing Scheme](https://en.wikipedia.org/wiki/Probabilistic_signature_scheme) |
> | PSS_SHA256      | [Probabilistic Signing Scheme](https://en.wikipedia.org/wiki/Probabilistic_signature_scheme) |
> | PSS_SHA512      | [Probabilistic Signing Scheme](https://en.wikipedia.org/wiki/Probabilistic_signature_scheme) |

The following RSASignModes are **deprecated** and thus should not be used:

> | Enum     | Description                                                                         |
> |----------|-------------------------------------------------------------------------------------|
> | SHA1     | [SHA1 algorithm (160-bit (20-byte) hash value)](http://en.wikipedia.org/wiki/Sha1)  |
> | SHA2_256 | [SHA256 algorithm (SHA-2 with 256 bit digest)](http://en.wikipedia.org/wiki/Sha256) |
> | SHA2_512 | [SHA512 algorithm (SHA-2 with 512 bit digest)](http://en.wikipedia.org/wiki/Sha512) |

## Method descriptions

<div id="crypto.aesdecrypt">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.AESDecrypt

**AESDecrypt**(publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Decrypts the data using the specified *key*.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

<div id="crypto.aesencrypt">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.AESEncrypt

**AESEncrypt**(publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Encrypts the data using the specified *key*.
>
> An initialization vector (IV) is a block of bits that is used by several modes to randomize the encryption and hence to produce distinct ciphertexts even if the same plaintext is encrypted multiple times, without the need for a slower re-keying process.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

<div id="crypto.berdecodeprivatekey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.BERDecodePrivateKey

**BERDecodePrivateKey**(privateKey As `String</api/data_types/string>`) As `MemoryBlock</api/language/memoryblock>`

> Decodes a private key for interoperability with the BER encoding for use by other libraries.
>
> For more information, see: <http://www.cryptopp.com/wiki/Keys_and_Formats#BER_and_DER_Encoding>
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

<div id="crypto.berdecodepublickey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.BERDecodePublicKey

**BERDecodePublicKey**(publicKey As `String</api/data_types/string>`) As `MemoryBlock</api/language/memoryblock>`

> Decodes a public key for interoperability with the BER encoding for use by other libraries.
>
> For more information, see: <http://www.cryptopp.com/wiki/Keys_and_Formats#BER_and_DER_Encoding>
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

<div id="crypto.blowfishdecrypt">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.BlowFishDecrypt

**BlowFishDecrypt**(publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Decrypts the data using the specified *key*.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

<div id="crypto.blowfishencrypt">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.BlowFishEncrypt

**BlowFishEncrypt**(publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Encrypts the data using the specified *key*.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

<div id="crypto.derencodeprivatekey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.DEREncodePrivateKey

**DEREncodePrivateKey**(privateKey As `String</api/data_types/string>`) As `MemoryBlock</api/language/memoryblock>`

> Encodes a private key for interoperability with the DER encoding for use by other libraries.
>
> For more information, see: <http://www.cryptopp.com/wiki/Keys_and_Formats#BER_and_DER_Encoding>
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

<div id="crypto.derencodepublickey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.DEREncodePublicKey

**DEREncodePublicKey**(publicKey As `String</api/data_types/string>`) As `MemoryBlock</api/language/memoryblock>`

> Encodes a public key for interoperability with the DER encoding for use by other libraries.
>
> For more information, see: <http://www.cryptopp.com/wiki/Keys_and_Formats#BER_and_DER_Encoding>
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

<div id="crypto.ed25519generatekeypair">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.ED25519GenerateKeyPair

**ED25519GenerateKeyPair**(`ByRef</api/language/byref>` PrivateKey As `String</api/data_types/string>`, `ByRef</api/language/byref>` PublicKey As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> Generates a private and public key pair that is hex encoded. Returns `True</api/language/true>` on success, `False</api/language/false>` if failed.
>
> Generate 256-bit private and public keys:
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android and Linux x86 64-bit.
>
> </div>
>
> Generate 1024-bit private and public keys:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.ED25519GenerateKeyPair(privateKey, publicKey) Then
>   ' 256-bit private and public keys were generated
> End If
> ```

<div id="crypto.ed25519sign">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.ED25519Sign

**ED25519Sign**(data As `MemoryBlock</api/language/memoryblock>`, privateKey As `String</api/data_types/string>`) As `MemoryBlock</api/language/memoryblock>`

> Encodes the *data* with the *privatekey* using ED25519 and returns it as a `MemoryBlock</api/language/memoryblock>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android and Linux x86 64-bit.
>
> </div>

<div id="crypto.ed25519verifykey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.ED25519VerifyKey

**ED25519VerifyKey**(Key As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> Attempts to validate the specified public or private key passed.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android and Linux x86 64-bit.
>
> </div>
>
> Verifies the generated public key:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.ED25519GenerateKeyPair(privateKey, publicKey) Then
>   ' 256-bit private and public keys were generated
>
>   If Crypto.ED25519VerifyKey(publicKey) Then
>     ' publicKey is valid
>   End If
>
> End If
> ```
>
> Verification fails on a "fake" key:
>
> ``` xojo
> If Crypto.ED25519VerifyKey("not a real key!") Then
>   MessageBox("Valid!")
> Else
>   MessageBox("Not valid!")
> End If
> ```

<div id="crypto.ed25519verifysignature">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.ED25519VerifySignature

**ED25519VerifySignature**(data As `MemoryBlock</api/language/memoryblock>`, signature As `MemoryBlock</api/language/memoryblock>`, publicKey As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> Verifies the *data* using the specified *signature* and key. Returns `True</api/language/true>` if the signature is verified, `False</api/language/false>` if it is not.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android and Linux x86 64-bit.
>
> </div>
>
> Verify a message:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.ED25519GenerateKeyPair(privateKey, publicKey) Then
>   ' 256-bit private and public keys were generated
>
>   Var msg As String = "this is a test"
>   Var signature As MemoryBlock = Crypto.ED25519Sign(msg, privateKey)
>
>   If signature <> Nil Then ' msg was successfully signed
>
>     ' Verify signature
>     If Crypto.ED25519VerifySignature(msg, signature, publicKey) Then
>       ' signature is valid
>     End If
>
>   End If
> End If
> ```

<div id="crypto.es256generatekeypair">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.ES256GenerateKeyPair

**ES256GenerateKeyPair**(`ByRef</api/language/byref>` PrivateKey As `String</api/data_types/string>`, `ByRef</api/language/byref>` PublicKey As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> Generates a private and public key pair that is hex encoded. Returns `True</api/language/true>` on success, `False</api/language/false>` if failed.
>
> Generate 256-bit private and public keys:
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>
>
> Generate 1024-bit private and public keys:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.ES256GenerateKeyPair(privateKey, publicKey) Then
>   ' 256-bit private and public keys were generated
> End If
> ```

<div id="crypto.es256sign">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.ES256Sign

**ES256Sign**(data As `MemoryBlock</api/language/memoryblock>`, privateKey As `String</api/data_types/string>`) As `MemoryBlock</api/language/memoryblock>`

> Encodes the *data* with the *privatekey* using ED256 and returns it as a `MemoryBlock</api/language/memoryblock>`.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android and Linux 64-bit.
>
> </div>

<div id="crypto.es256verifykey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.ES256VerifyKey

**ES256VerifyKey**(Key As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> Attempts to validate the specified public or private key passed.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>
>
> Verifies the generated public key:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.ES256GenerateKeyPair(privateKey, publicKey) Then
>   ' 256-bit private and public keys were generated
>
>   If Crypto.ES256VerifyKey(publicKey) Then
>     ' publicKey is valid
>   End If
>
> End If
> ```
>
> Verification fails on a "fake" key:
>
> ``` xojo
> If Crypto.ES256VerifyKey("not a real key!") Then
>   MessageBox("Valid!")
> Else
>   MessageBox("Not valid!")
> End If
> ```

<div id="crypto.es256verifysignature">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.ES256VerifySignature

**ES256VerifySignature**(data As `MemoryBlock</api/language/memoryblock>`, signature As `MemoryBlock</api/language/memoryblock>`, publicKey As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> Verifies the *data* using the specified *signature* and key. Returns `True</api/language/true>` if the signature is verified, `False</api/language/false>` if it is not.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>
>
> Verify a message:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.ES256GenerateKeyPair(privateKey, publicKey) Then
>   ' 256-bit private and public keys were generated
>
>   Var msg As String = "this is a test"
>   Var signature As MemoryBlock = Crypto.ES256Sign(msg, privateKey)
>
>   If signature <> Nil Then ' msg was successfully signed
>
>     ' Verify signature
>     If Crypto.ES256VerifySignature(msg, signature, publicKey) Then
>       ' signature is valid
>     End If
>
>   End If
> End If
> ```

<div id="crypto.generaterandombytes">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.GenerateRandomBytes

**GenerateRandomBytes**(ByteCount As `Integer</api/data_types/integer>`) As `MemoryBlock</api/language/memoryblock>`

> Generates a random block of data.

<div id="crypto.hash">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.Hash

**Hash**(data As `MemoryBlock</api/language/memoryblock>`, hashAlgorithm As `Crypto.HashAlgorithms<crypto.hashalgorithms>`) As `MemoryBlock</api/language/memoryblock>`

> Creates a hash value for the *data* using the specified *hashAlgorithm*.
>
> See the `Crypto<crypto.hashalgorithms>` enumeration for values that can be used specify the type of Hash.
>
> This code calculates a hash for a password using SHA512:
>
> ``` xojo
> Var hash As String
> hash = Crypto.Hash("YourPasswordSentence", Crypto.HashAlgorithms.SHA512)
> ```

<div id="crypto.hmac">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.HMAC

**HMAC**(key As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, hashAlgorithm As `Crypto.HashAlgorithms<crypto.hashalgorithms>`) As `MemoryBlock</api/language/memoryblock>`

> Creates the hash-based message authentication code using the *data* and the supplied *key* value and the supplied *hashAlgorithm*.
>
> The *key* value is applied to the *data* before generating the hash.
>
> See [HMAC on Wikipedia](http://en.wikipedia.org/wiki/Hash-based_message_authentication_code).
>
> Use the `Crypto<crypto.hashalgorithms>` enumeration with the Hash method to specify the type of hash. It has these values:
>
> - MD5
> - SHA1
> - SHA2_256
> - SHA2_512
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> HMAC does not support CRC32, SHA3_256 and SHA3_512 modes. Using them will raise an `UnsupportedOperationException</api/exceptions/unsupportedoperationexception>`.
>
> </div>
>
> This example creates a hash using HMAC and SHA512:
>
> ``` xojo
> Var hash As String
> hash = Crypto.HMAC("SaltValue", "YourPasswordSentence", Crypto.HashAlgorithms.SHA512)
> ```

<div id="crypto.md5">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.MD5

**MD5**(data As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Returns the MD5 message-digest value of the *data*.
>
> Works the same as the `MD5</api/cryptography/md5>` function.
>
> ``` xojo
> Var md5Value As MemoryBlock
> md5Value = Crypto.MD5("SomeStringData")
>
> Var hexValue As String = EncodeHex(md5Value)
> ' hexValue = 1E7984567DBC8AF6A48102C5E71A08E9
> ```
>
> This above is equivalent to calling the Hash method with MD5 as the algorithm:
>
> ``` xojo
> Var md5Value As MemoryBlock
> md5Value = Crypto.Hash("SomeStringData", Crypto.Algorithm.MD5)
>
> Var hexValue As String = EncodeHex(md5Value)
> ' hexValue = 1E7984567DBC8AF6A48102C5E71A08E9
> ```

<div id="crypto.pbkdf2">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.PBKDF2

**PBKDF2**(salt As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, iterations As `Integer</api/data_types/integer>`, desiredHashLength As `Integer</api/data_types/integer>`, hashAlgorithm As `Crypto.hashAlgorithm<crypto.hashalgorithms>`) As `MemoryBlock</api/language/memoryblock>`

> Returns the PBKDF2 hash value of the *data*, first applying the *salt* value and using the specified *hashAlgorithm*. The *iteration* parameter is the number of loops that the hash algorithm does. The *desiredHashLength* parameter lets you specify the number of bytes that you want the resulting hash to be. 16 or 32 bytes are commonly used.
>
> PBKDF2 is a "slow", i.e. deliberately processing intensive, algorithm for generating hash values. Slow is relative, for generating a single hash value it is plenty fast. The benefit of a slow algorithm is that it is impractical for hackers to generate hash tables using it because it would take too long to generate the thousands of hashes for commonly used values.
>
> Use a higher value for *iterations' to further slow the hash creation.*
>
> Refer to [PBKDF2](http://en.wikipedia.org/wiki/Pbkdf2) on Wikipedia.
>
> Use the `Crypto<crypto.hashalgorithms>` enumeration with the Hash method to specify the type of hash. It has these values:
>
> - MD5
> - SHA1
> - SHA2_256
> - SHA2_512
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> PBKDF2 does not support CRC32, SHA3_256 and SHA3_512 modes. Using them will raise an `UnsupportedOperationException</api/exceptions/unsupportedoperationexception>`.
>
> </div>
>
> This example generates a 32-byte hash using PBKDF2 for the salt and data, iterating 100 times:
>
> ``` xojo
> Var hash As MemoryBlock
> hash = Crypto.PBKDF2("SaltValue", "YourPasswordSentence", 100, 32, Crypto.HashAlgorithms.SHA512)
>
> Var hashValue As String = EncodeHex(hash)
> ' FB8F64E66A72517AC7CA70145640B1932A986A7A7DDE7EC79602F8CE94DE0F8A
> ```

<div id="crypto.rsadecrypt">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.RSADecrypt

**RSADecrypt**(Data As `MemoryBlock</api/language/memoryblock>`, PrivateKey As `String</api/data_types/string>`) As `MemoryBlock</api/language/memoryblock>`

> Decrypts data using the specified key, which is either a private or public key.
>
> Decrypt a message:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.RSAGenerateKeyPair(1024, privateKey, publicKey) Then
>   ' 1024-bit private and public keys were generated
>
>   Const kMessage = "this is a test"
>
>   Var msg As New MemoryBlock(14)
>   msg.StringValue(0, 14) = kMessage
>
>   ' Encrypt msg using the publicKey
>   Var encryptedData As MemoryBlock = Crypto.RSAEncrypt(msg, publicKey)
>
>   If encryptedData <> Nil Then
>     MessageBox("Successfully encrypted.")
>
>     ' Now decrypt
>     Var decryptedData As MemoryBlock = Crypto.RSADecrypt(encryptedData, privateKey)
>     MessageBox("DecryptedData=" + decryptedData.StringValue(0, 14))
>   End If
> End If
> ```

<div id="crypto.rsaencrypt">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.RSAEncrypt

**RSAEncrypt**(Data As `MemoryBlock</api/language/memoryblock>`, PublicKey As `String</api/data_types/string>`) As `MemoryBlock</api/language/memoryblock>`

> Encrypts the data using the specified *PublicKey*.
>
> Attempting to encrypt using a PrivateKey raises a `CryptoException</api/exceptions/cryptoexception>`.
>
> Encrypt some text:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.RSAGenerateKeyPair(1024, privateKey, publicKey) Then
>   ' 1024-bit private and public keys were generated
>
>   Const kMessage = "this is a test"
>
>   Var msg As New MemoryBlock(14)
>   msg.StringValue(0, 14) = kMessage
>
>   ' Encrypt msg using the publicKey
>   Var encryptedData As MemoryBlock = Crypto.RSAEncrypt(msg, publicKey)
>
>   If encryptedData <> Nil Then
>     MessageBox("Successfully encrypted.")
>   End If
> End If
> ```

<div id="crypto.rsageneratekeypair">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.RSAGenerateKeyPair

**RSAGenerateKeyPair**(Bits As `Integer</api/data_types/integer>`, `ByRef</api/language/byref>` PrivateKey As `String</api/data_types/string>`, `ByRef</api/language/byref>` PublicKey As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> Generates a private and public key pair that is hex encoded. Returns `True</api/language/true>` on success, `False</api/language/false>` if failed. Bits is usually 1024 or 2048.
>
> Generate 1024-bit private and public keys:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.RSAGenerateKeyPair(1024, privateKey, publicKey) Then
>   ' 1024-bit private and public keys were generated
> End If
> ```

<div id="crypto.rsasign">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.RSASign

**RSASign**(data As `MemoryBlock</api/language/memoryblock>`, privateKey As `String</api/data_types/string>`, mode As `Crypto.RSASignModes.SHA1<crypto.rsasignmodes>`) As `MemoryBlock</api/language/memoryblock>`

> Signs the *data* block using the specified *privateKey* using PKCS v1.5 with SHA1.
>
> Sign a message:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.RSAGenerateKeyPair(1024, privateKey, publicKey) Then
>   ' 1024-bit private and public keys were generated
>
>   Var msg As String = "this is a test"
>   Var signature As MemoryBlock = Crypto.RSASign(msg, privateKey)
>
>   If signature <> Nil Then
>     ' msg was successfully signed
>   End If
> End If
> ```

<div id="crypto.rsaverifykey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.RSAVerifyKey

**RSAVerifyKey**(Key As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

> Attempts to validate the specified key.
>
> Verifies the generated public key:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.RSAGenerateKeyPair(1024, privateKey, publicKey) Then
>   ' 1024-bit private and public keys were generated
>
>   If Crypto.RSAVerifyKey(publicKey) Then
>     ' publicKey is valid
>   End If
>
> End If
> ```
>
> Verification fails on a "fake" key:
>
> ``` xojo
> If Crypto.RSAVerifyKey("not a real key!") Then
>   MessageBox("Valid!")
> Else
>   MessageBox("Not valid!")
> End If
> ```

<div id="crypto.rsaverifysignature">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.RSAVerifySignature

**RSAVerifySignature**(data As `MemoryBlock</api/language/memoryblock>`, signature As `MemoryBlock</api/language/memoryblock>`, publicKey As `String</api/data_types/string>`, mode As `Crypto.RSASignModes.SHA1<crypto.rsasignmodes>`) As `Boolean</api/data_types/boolean>`

> Verifies the *data* using the specified *signature* and key using PKCS v1.5 with SHA1. Returns `True</api/language/true>` if the signature is verified, `False</api/language/false>` if it is not.
>
> Verify a message:
>
> ``` xojo
> Var privateKey As String
> Var publicKey As String
>
> If Crypto.RSAGenerateKeyPair(1024, privateKey, publicKey) Then
>   ' 1024-bit private and public keys were generated
>
>   Var msg As String = "this is a test"
>   Var signature As MemoryBlock = Crypto.RSASign(msg, privateKey)
>
>   If signature <> Nil Then ' msg was successfully signed
>
>     ' Verify signature
>     If Crypto.RSAVerifySignature(msg, signature, publicKey) Then
>       ' signature is valid
>     End If
>
>   End If
> End If
> ```

<div id="crypto.sha1">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.SHA1

**SHA1**(data As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Returns the SHA1 hash value of the *data*.
>
> Refer to [SHA1](http://en.wikipedia.org/wiki/Sha1) on Wikipedia.
>
> This is equivalent of calling the Hash method with SHA1 as the algorithm:
>
> ``` xojo
> Var encryptedValue As String
> encryptedValue = Crypto.Hash("DataToEncrypt", Crypto.HashAlgorithms.SHA1)
> ```

<div id="crypto.sha2_256">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.SHA2_256

**SHA2_256**(data As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Returns the SHA256 hash value of the *data*.
>
> Refer to [SHA256](http://en.wikipedia.org/wiki/Sha256) on Wikipedia.
>
> This is equivalent of calling the Hash method with SHA256 as the algorithm:
>
> ``` xojo
> Var encryptedValue As String
> encryptedValue = Crypto.Hash("DataToEncrypt", Crypto.HashAlgorithms.SHA256)
> ```

<div id="crypto.sha2_512">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.SHA2_512

**SHA2_512**(data As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Returns the SHA512 hash value of the *data*.
>
> Refer to [SHA512](http://en.wikipedia.org/wiki/Sha512) on Wikipedia.
>
> This is equivalent of calling the Hash method with SHA512 as the algorithm:
>
> ``` xojo
> Var encryptedValue As String
> encryptedValue = Crypto.Hash("DataToEncrypt", Crypto.HashAlgorithms.SHA512)
> ```

<div id="crypto.sha3_256">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.SHA3_256

**SHA3_256**(data As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Returns the SHA3_256 hash value of the *data*.
>
> Refer to [SHA-3](https://en.wikipedia.org/wiki/SHA-3) on Wikipedia.
>
> This is equivalent of calling the Hash method with SHA3_256 as the algorithm:
>
> ``` xojo
> Var encryptedValue As String
> encryptedValue = Crypto.Hash("DataToEncrypt", Crypto.HashAlgorithms.SHA3_256)
> ```

<div id="crypto.sha3_512">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.SHA3_512

**SHA3_512**(data As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Returns the SHA3_512 hash value of the *data*.
>
> Refer to [SHA-3](http://en.wikipedia.org/wiki/SHA-3) on Wikipedia.
>
> This is equivalent of calling the Hash method with SHA3_512 as the algorithm:
>
> ``` xojo
> Var encryptedValue As String
> encryptedValue = Crypto.Hash("DataToEncrypt", Crypto.HashAlgorithms.SHA3_512)
> ```

<div id="crypto.twofishdecrypt">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.TwoFishDecrypt

**TwoFishDecrypt**(publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto.BlockModes<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Decrypts the data using the specified *key*.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

<div id="crypto.twofishencrypt">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Crypto.TwoFishEncrypt

**TwoFishEncrypt**(publicKey As `String</api/data_types/string>`, data As `MemoryBlock</api/language/memoryblock>`, blockMode As `Crypto.BlockModes<crypto.blockmodes>` = `BlockModes.CBC<crypto.blockmodes>`, initializationVector As `MemoryBlock</api/language/memoryblock>`) As `MemoryBlock</api/language/memoryblock>`

> Encrypts the data using the specified *key*.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This method is not currently supported for Android.
>
> </div>

## Notes

Uses <span class="title-ref">Crypto</span>++ [Library 5.6.5](http://cryptopp.com).

Use the `HashAlgorithms<crypto.hashalgorithms>` enumeration with the Hash method to specify the type of hash.

Should any <span class="title-ref">Crypto</span> function fail, a `CryptoException</api/exceptions/cryptoexception>` will be raised.

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`CryptoException</api/exceptions/cryptoexception>` class.

</div>
