小编Sta*_*nov的帖子

将.net aes256加密代码转换为php

下面的代码是一个简单的.NET代码段,test在输入上它p+cTm2VODfvQnreAl02wUQ==作为输出返回.

Dim aesEncryptObj As New System.Security.Cryptography.RijndaelManaged()
Dim encoder As System.Text.ASCIIEncoding = New System.Text.ASCIIEncoding()

Dim tempKey As Byte() = encoder.GetBytes("00000011111111111111111111111111")
aesEncryptObj.Key = tempKey
aesEncryptObj.BlockSize = 128
aesEncryptObj.Mode = System.Security.Cryptography.CipherMode.ECB
aesEncryptObj.Padding = System.Security.Cryptography.PaddingMode.PKCS7
aesEncryptObj.GenerateIV()

Dim EncryptedBytes As Byte()
Dim encryptor As System.Security.Cryptography.ICryptoTransform = aesEncryptObj.CreateEncryptor(aesEncryptObj.Key, aesEncryptObj.IV)

Using msEncrypt As New System.IO.MemoryStream()
    Using csEncrypt As New System.Security.Cryptography.CryptoStream(msEncrypt, encryptor, System.Security.Cryptography.CryptoStreamMode.Write)
        Using swEncrypt As New System.IO.StreamWriter(csEncrypt)
            swEncrypt.Write(txtInput.Text)
        End Using
        EncryptedBytes = msEncrypt.ToArray()
    End Using
End Using

txtOutput.Text = Convert.ToBase64String(EncryptedBytes)
Run Code Online (Sandbox Code Playgroud)

现在,这是PHP代码:

const ENCRYPT_METHOD …
Run Code Online (Sandbox Code Playgroud)

.net php encryption aes php-openssl

2
推荐指数
1
解决办法
175
查看次数

Yii2活动表格,请在用ajax提交时等待消息

我正在使用Yii2的高级模板,并在向服务器发送登录表单时寻找显示"请稍候..."消息的对话框的方法.

这是我的活动表单代码:

            <?php $form = ActiveForm::begin([
                'id' => $model->formName(),
                'enableAjaxValidation' => true,
            ]); ?>
                <fieldset>

                    <?= $form->field($model, 'username', [
                        'inputOptions' => [
                            'placeholder' => $model->getAttributeLabel('username'),
                        ],
                    ])->label(false); ?>

                    <?= $form->field($model, 'password', [
                        'inputOptions' => [
                            'placeholder' => $model->getAttributeLabel('password'),
                        ],
                    ])->label(false)->passwordInput() ?>

                    <?= $form->field($model, 'rememberMe')->checkbox() ?>

                    <?= Html::submitButton('Login', ['class' => 'btn btn-lg btn-success btn-block', 'name' => 'login-button']) ?>
                </fieldset>
            <?php ActiveForm::end(); ?>
Run Code Online (Sandbox Code Playgroud)

我的服务器端操作:

public function actionLogin()
{
    if (!\Yii::$app->user->isGuest) {
        return $this->goHome();
    }

    $model = new LoginForm();
    if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) …
Run Code Online (Sandbox Code Playgroud)

php ajax dialog yii2 active-form

1
推荐指数
1
解决办法
5364
查看次数

标签 统计

php ×2

.net ×1

active-form ×1

aes ×1

ajax ×1

dialog ×1

encryption ×1

php-openssl ×1

yii2 ×1