This post was updated 535 days ago and some of the ideas may be out of date.


<!doctype html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src=""></script>
    function rc4(content, key, operation) {
        const iv = CryptoJS.enc.Utf8.parse(key.substring(0, 16));
        key = CryptoJS.enc.Utf8.parse(CryptoJS.MD5(key).toString());
        if (operation) {
            return CryptoJS.RC4.decrypt(content, key, {
                iv: iv,
                padding: CryptoJS.pad.Pkcs7
        return CryptoJS.RC4.encrypt(content, key, {
            iv: iv,
            mode: CryptoJS.mode.CBC,
            padding: CryptoJS.pad.Pkcs7

    console.log(rc4('hello world', '1234567890', false));




 * Created by PhpStorm.
 * User: LinFei
 * Created time 2023/01/17 17:41:47
 * E-mail:

function rc4(string $content, string $key, $operation = false)
    $key = md5($key);
    if ($operation) {
        return openssl_decrypt(base64_decode($content), 'rc4', $key, OPENSSL_RAW_DATA);
    return base64_encode(openssl_encrypt($content, 'rc4', $key, OPENSSL_RAW_DATA));

var_dump(rc4('LJi8Ufyb3iu4PjQ=', '1234567890', true));