fix
This commit is contained in:
@@ -30,6 +30,7 @@ class App extends Plugin
|
|||||||
private $coded;
|
private $coded;
|
||||||
private $opensslPadding;
|
private $opensslPadding;
|
||||||
private $opensslAlgo = 1;
|
private $opensslAlgo = 1;
|
||||||
|
private $dataType;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -47,6 +48,7 @@ class App extends Plugin
|
|||||||
$this->sign = request()->param("sign");
|
$this->sign = request()->param("sign");
|
||||||
$this->opensslPadding = request()->param("openssl_padding");
|
$this->opensslPadding = request()->param("openssl_padding");
|
||||||
$this->opensslAlgo = intval(request()->param("openssl_algo"));
|
$this->opensslAlgo = intval(request()->param("openssl_algo"));
|
||||||
|
$this->dataType = request()->param("data_type");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
@@ -86,7 +88,7 @@ class App extends Plugin
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (openssl_private_encrypt($this->origin, $encrypted, $this->getRsaPrivateKey(), $this->opensslPadding)) {
|
if (openssl_private_encrypt($this->origin, $encrypted, $this->getRsaPrivateKey(), $this->opensslPadding)) {
|
||||||
return msg('ok', 'success', base64_encode($encrypted));
|
return msg('ok', 'success', $this->dataType == 'hex' ? bin2hex($encrypted) : base64_encode($encrypted));
|
||||||
}
|
}
|
||||||
return msg('error', '加密失败');
|
return msg('error', '加密失败');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -124,7 +126,7 @@ class App extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($string) {
|
if ($string) {
|
||||||
return msg('ok', 'success', base64_encode($string));
|
return msg('ok', 'success', $this->dataType == 'hex' ? bin2hex($string) : base64_encode($string));
|
||||||
}
|
}
|
||||||
return msg('error', '加密失败');
|
return msg('error', '加密失败');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -143,7 +145,8 @@ class App extends Plugin
|
|||||||
return msg('error', '解密失败');
|
return msg('error', '解密失败');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (openssl_private_decrypt(base64_decode($this->coded), $decrypted, $this->getRsaPrivateKey(), $this->opensslPadding)) {
|
$encrypted = $this->dataType == 'hex' ? hex2bin($this->coded) : base64_decode($this->coded);
|
||||||
|
if (openssl_private_decrypt($encrypted, $decrypted, $this->getRsaPrivateKey(), $this->opensslPadding)) {
|
||||||
return msg('ok', 'success', $decrypted);
|
return msg('ok', 'success', $decrypted);
|
||||||
}
|
}
|
||||||
return msg('error', '解密失败');
|
return msg('error', '解密失败');
|
||||||
@@ -165,7 +168,8 @@ class App extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (openssl_public_decrypt(base64_decode($this->coded), $decrypted, $this->rsaPublicKey, $this->opensslPadding)) {
|
$encrypted = $this->dataType == 'hex' ? hex2bin($this->coded) : base64_decode($this->coded);
|
||||||
|
if (openssl_public_decrypt($encrypted, $decrypted, $this->rsaPublicKey, $this->opensslPadding)) {
|
||||||
return msg('ok', 'success', $decrypted);
|
return msg('ok', 'success', $decrypted);
|
||||||
}
|
}
|
||||||
return msg('error', '解密失败');
|
return msg('error', '解密失败');
|
||||||
|
|||||||
@@ -74,6 +74,13 @@
|
|||||||
<option v-for="v,index in openssl_padding" :value="index+1">{{v}}</option>
|
<option v-for="v,index in openssl_padding" :value="index+1">{{v}}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">密文数据类型</label>
|
||||||
|
<select class="form-control" v-model="crypto_from.data_type">
|
||||||
|
<option value="base64">Base64</option>
|
||||||
|
<option value="hex">Hex(十六进制)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label">加密/解密方式</label>
|
<label class="form-label">加密/解密方式</label>
|
||||||
<select class="form-control" v-model="crypto_from.type">
|
<select class="form-control" v-model="crypto_from.type">
|
||||||
@@ -113,6 +120,13 @@
|
|||||||
<option v-for="v,index in openssl_algo" :value="index+1">{{v}}</option>
|
<option v-for="v,index in openssl_algo" :value="index+1">{{v}}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">签名数据类型</label>
|
||||||
|
<select class="form-control" v-model="sign_form.data_type">
|
||||||
|
<option value="base64">Base64</option>
|
||||||
|
<option value="hex">Hex(十六进制)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="row pt-1 pb-1 mb-3">
|
<div class="row pt-1 pb-1 mb-3">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<button class="btn btn-dim btn-outline-secondary btn-block card-link" @click="sign">
|
<button class="btn btn-dim btn-outline-secondary btn-block card-link" @click="sign">
|
||||||
@@ -336,12 +350,14 @@ function base64ToPem(base64Key, type) {
|
|||||||
},
|
},
|
||||||
crypto_from: {
|
crypto_from: {
|
||||||
openssl_padding: 1,
|
openssl_padding: 1,
|
||||||
|
data_type: 'base64',
|
||||||
type: 0,
|
type: 0,
|
||||||
origin: '',
|
origin: '',
|
||||||
coded: ''
|
coded: ''
|
||||||
},
|
},
|
||||||
sign_form: {
|
sign_form: {
|
||||||
openssl_algo: 1,
|
openssl_algo: 1,
|
||||||
|
data_type: 'base64',
|
||||||
data: "",
|
data: "",
|
||||||
sign: "",
|
sign: "",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -56,9 +56,7 @@ textarea.form-control{min-height: auto;}
|
|||||||
<h6><em class="icon ni ni-info"></em> 工具说明</h6>
|
<h6><em class="icon ni ni-info"></em> 工具说明</h6>
|
||||||
<div class="accordion-inner">
|
<div class="accordion-inner">
|
||||||
<p>文件格式支持:jpg,jpeg,png,gif,webp,大小不能超过10M</p>
|
<p>文件格式支持:jpg,jpeg,png,gif,webp,大小不能超过10M</p>
|
||||||
<p>OPPO:图片域名store.heytapimage.com,原图无压缩</p>
|
<p>有的接口经常会失效,可更换另外的接口尝试</p>
|
||||||
<p>58同城:图片域名58cdn.com.cn,原图无压缩</p>
|
|
||||||
<p>大众点评:图片域名p1.meituan.net,原图无压缩</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -102,10 +100,6 @@ textarea.form-control{min-height: auto;}
|
|||||||
title: '大众点评',
|
title: '大众点评',
|
||||||
key: 'dianping'
|
key: 'dianping'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: 'OPPO',
|
|
||||||
key: 'oppo'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: 'VIPKID',
|
title: 'VIPKID',
|
||||||
key: 'vipkid'
|
key: 'vipkid'
|
||||||
|
|||||||
Reference in New Issue
Block a user