Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
function rc4 { param( [Byte[]]$data, [Byte[]]$key ) # Make a copy of..
Decoded Output download
<? function rc4 {
param(
[Byte[]]$data,
[Byte[]]$key
)
# Make a copy of the input data
[Byte[]]$buffer = New-Object Byte[] $data.Length
$data.CopyTo($buffer, 0)
[Byte[]]$s = New-Object Byte[] 256;
[Byte[]]$k = New-Object Byte[] 256;
for ($i = 0; $i -lt 256; $i++)
{
$s[$i] = [Byte]$i;
$k[$i] = $key[$i % $key.Length];
}
$j = 0;
for ($i = 0; $i -lt 256; $i++)
{
$j = ($j + $s[$i] + $k[$i]) % 256;
$temp = $s[$i];
$s[$i] = $s[$j];
$s[$j] = $temp;
}
$i = $j = 0;
for ($x = 0; $x -lt $buffer.Length; $x++)
{
$i = ($i + 1) % 256;
$j = ($j + $s[$i]) % 256;
$temp = $s[$i];
$s[$i] = $s[$j];
$s[$j] = $temp;
[int]$t = ($s[$i] + $s[$j]) % 256;
$buffer[$x] = $buffer[$x] -bxor $s[$t];
}
return $buffer
}
$enc = [System.Text.Encoding]::ASCII
# The data we're going to encrypt
[Byte[]]$data = $enc.GetBytes("Hello World!")
# The key we're going to use
[Byte[]]$key = $enc.GetBytes("SECRET")
# Encryp the data, a byte array is returned
$EncryptedBytes = rc4 $data $key
Write-Host "Base64 of ciphertext: $([Convert]::ToBase64String($EncryptedBytes))"
# Now decrypt the data
$DecryptedBytes = rc4 $EncryptedBytes $key
Write-Host "Base64 of plaintext: $([Convert]::ToBase64String($DecryptedBytes))" ?>
Did this file decode correctly?
Original Code
function rc4 {
param(
[Byte[]]$data,
[Byte[]]$key
)
# Make a copy of the input data
[Byte[]]$buffer = New-Object Byte[] $data.Length
$data.CopyTo($buffer, 0)
[Byte[]]$s = New-Object Byte[] 256;
[Byte[]]$k = New-Object Byte[] 256;
for ($i = 0; $i -lt 256; $i++)
{
$s[$i] = [Byte]$i;
$k[$i] = $key[$i % $key.Length];
}
$j = 0;
for ($i = 0; $i -lt 256; $i++)
{
$j = ($j + $s[$i] + $k[$i]) % 256;
$temp = $s[$i];
$s[$i] = $s[$j];
$s[$j] = $temp;
}
$i = $j = 0;
for ($x = 0; $x -lt $buffer.Length; $x++)
{
$i = ($i + 1) % 256;
$j = ($j + $s[$i]) % 256;
$temp = $s[$i];
$s[$i] = $s[$j];
$s[$j] = $temp;
[int]$t = ($s[$i] + $s[$j]) % 256;
$buffer[$x] = $buffer[$x] -bxor $s[$t];
}
return $buffer
}
$enc = [System.Text.Encoding]::ASCII
# The data we're going to encrypt
[Byte[]]$data = $enc.GetBytes("Hello World!")
# The key we're going to use
[Byte[]]$key = $enc.GetBytes("SECRET")
# Encryp the data, a byte array is returned
$EncryptedBytes = rc4 $data $key
Write-Host "Base64 of ciphertext: $([Convert]::ToBase64String($EncryptedBytes))"
# Now decrypt the data
$DecryptedBytes = rc4 $EncryptedBytes $key
Write-Host "Base64 of plaintext: $([Convert]::ToBase64String($DecryptedBytes))"
Function Calls
None |
Stats
MD5 | 896e424ab2cedb45568e5540336d101a |
Eval Count | 0 |
Decode Time | 108 ms |