Method

# MD5

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

## Description

Returns the <span class="title-ref">MD5</span> message-digest value of a `String</api/data_types/string>`. This is the raw data as bytes, so convert it to something such as hexadecimal to display it.

## Usage

``` xojo
result = MD5(str)
```

| Part   | Type                             | Description                                                                                                |
|--------|----------------------------------|------------------------------------------------------------------------------------------------------------|
| result | `String</api/data_types/string>` | The <span class="title-ref">MD5</span> message digest form of the passed `String</api/data_types/string>`. |
| str    | `String</api/data_types/string>` | The input string to be parsed.                                                                             |

## Notes

The <span class="title-ref">MD5</span> function uses the RSA Data Security, Inc. <span class="title-ref">MD5</span> Message-Digest Algorithm. The <span class="title-ref">MD5</span> algorithm is intended for digital signature applications, where a file must be compressed in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA. It is a technology for verifying data integrity and is similar in concept to checksum techniques.

Use the <span class="title-ref">MD5</span> function to process the raw data to be processed. For complete information on the <span class="title-ref">MD5</span> message digest format, see RFC 1321.

The `MD5Digest</api/cryptography/md5digest>` class implements the same algorithm but is capable of processing a large file in segments. The <span class="title-ref">MD5</span> function is better suited for short strings that need to be encrypted such as passwords, account numbers, and private transaction strings.

To compare the <span class="title-ref">MD5</span> hash from an outside source like PHP often requires that the RB hash be converted to a hex string with `EncodeHex</api/text/encoding_text/encodehex>` for comparison.

## Sample code

``` xojo
Var bytes As String
bytes = MD5("Hello world")

' To display the hash, convert it to hexadecimal
Var hex As String
hex = EncodeHex(bytes)
MessageBox(hex)
```

## Compatibility

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

<div class="seealso">

`MD5Digest</api/cryptography/md5digest>` class; `Crypto.MD5<crypto.md5>` function

</div>
