# Using PHP's RC4Crypt to Interpret Data Encrypted by Meychi's RC4 (ASCrypt)

**URL:** <https://forum.kirupa.com/t/using-phps-rc4crypt-to-interpret-data-encrypted-by-meychis-rc4-ascrypt/287448>\
**Category:** programming\
**Created:** [May 1, 2009, 7:37am UTC](https://forum.kirupa.com/t/using-phps-rc4crypt-to-interpret-data-encrypted-by-meychis-rc4-ascrypt/287448 "2009-05-01T07:37:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nestoralvarez](https://avatars.discourse-cdn.com/v4/letter/n/71e660/32.png) [@nestoralvarez](https://forum.kirupa.com/u/nestoralvarez)\
**Post date:** [May 1, 2009, 7:37am UTC](https://forum.kirupa.com/t/using-phps-rc4crypt-to-interpret-data-encrypted-by-meychis-rc4-ascrypt/287448/1 "2009-05-01T07:37:43Z")

</div>

I’m sending encrypted data from Flash to PHP using LoadVars. While still in Flash, I’m using the RC4 class of Meychi’s ASCrypt package to encrypt said data. The encrypted data is being received by PHP successfully, and my key is correct. I’m having trouble decrypting the data, though. I think the root of my problem comes down to the nature of the arguments (hexadecimal v. binary). After some playing around, I’ve been able to reproduce ASCrypt’s output using PHP’s RC4Crypt, but I still can’t seem to figure out how to decrypt it.

Here’s a PHP script I’ve made that reproduces the encrypted data coming from Flash. Could anyone show me how to go about decrypting it???

```auto
require_once("scripts/rc4crypt.php");

$data = "The secret message is flewdendybewdendybop.";
$key = "1234567890";

$encryptedData = bin2hex(rc4crypt::encrypt($key, $data, 0));
//The next part is what needs fixed.
$decryptedData = rc4crypt::decrypt($key, $encryptedData, 0);

echo "<b>data:</b><br />$data<br /><br />";
echo "<b>key:</b><br />$key<br /><br />";
echo "<b>encryptedData:</b><br />$encryptedData<br /><br />";
echo "<b>decryptedData:</b><br />$decryptedData<br /><br />";

```

Meychi’s ASCrypt  
[http://www.jek2k.com/wp//wp/wp-content/uploads/2007/05/ascrypt\_sample.zip](http://www.jek2k.com/wp//wp/wp-content/uploads/2007/05/ascrypt_sample.zip)

RC4Crypt

> **[RC4 Crypt](https://sourceforge.net/projects/rc4crypt/)**
>
> Download RC4 Crypt for free. RC4Crypt is a petite library that allows you to use RC4 encryption easily in PHP. It's OO and can produce outputs in binary and hex.
