Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace WeChat\Prpcrypt; /** * PKCS7 - * Class PKCS7Encoder */ class PKCS7En..

Decoded Output download

<?php

namespace WeChat\Prpcrypt;

/**
 * PKCS7 - 
 * Class PKCS7Encoder
 */
class PKCS7Encoder
{

    public static $blockSize = 32;

    /**
     * 
     * @param string $text 
     * @return string 
     */
    function encode($text)
    {
        $amount_to_pad = PKCS7Encoder::$blockSize - (strlen($text) % PKCS7Encoder::$blockSize);
        if ($amount_to_pad == 0) {
            $amount_to_pad = PKCS7Encoder::$blockSize;
        }
        list($pad_chr, $tmp) = [chr($amount_to_pad), ''];
        for ($index = 0; $index < $amount_to_pad; $index++) {
            $tmp .= $pad_chr;
        }
        return $text . $tmp;
    }

    /**
     * 
     * @param string $text 
     * @return string 
     */
    function decode($text)
    {
        $pad = ord(substr($text, -1));
        if ($pad < 1 || $pad > PKCS7Encoder::$blockSize) {
            $pad = 0;
        }
        return substr($text, 0, strlen($text) - $pad);
    }

} ?>

Did this file decode correctly?

Original Code

<?php

namespace WeChat\Prpcrypt;

/**
 * PKCS7 - 
 * Class PKCS7Encoder
 */
class PKCS7Encoder
{

    public static $blockSize = 32;

    /**
     * 
     * @param string $text 
     * @return string 
     */
    function encode($text)
    {
        $amount_to_pad = PKCS7Encoder::$blockSize - (strlen($text) % PKCS7Encoder::$blockSize);
        if ($amount_to_pad == 0) {
            $amount_to_pad = PKCS7Encoder::$blockSize;
        }
        list($pad_chr, $tmp) = [chr($amount_to_pad), ''];
        for ($index = 0; $index < $amount_to_pad; $index++) {
            $tmp .= $pad_chr;
        }
        return $text . $tmp;
    }

    /**
     * 
     * @param string $text 
     * @return string 
     */
    function decode($text)
    {
        $pad = ord(substr($text, -1));
        if ($pad < 1 || $pad > PKCS7Encoder::$blockSize) {
            $pad = 0;
        }
        return substr($text, 0, strlen($text) - $pad);
    }

}

Function Calls

None

Variables

None

Stats

MD5 1678a9af03e5aa9697f378b3977aceed
Eval Count 0
Decode Time 96 ms