Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
7138b646
Commit
7138b646
authored
Mar 30, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
1944fcde
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
43 deletions
+17
-43
center-app/app/base/service/impl/utilsSve/utilsuserSve.js
+17
-43
No files found.
center-app/app/base/service/impl/utilsSve/utilsuserSve.js
View file @
7138b646
...
...
@@ -136,52 +136,20 @@ class UtilsUserSve extends AppServiceBase {
*/
async
getJsApiSingnature
(
pobj
,
ticket
,
nonce
,
timeStamp
,
url
)
{
//获取JsApi鉴权签名信息----本类中调用
// public static String sign(String ticket, String nonceStr, long timeStamp, String url) throws OApiException {
// String plain = "jsapi_ticket=" + ticket + "&noncestr=" + nonceStr + "×tamp=" + String.valueOf(timeStamp)
// + "&url=" + url;
// try {
// MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
// sha1.reset();
// sha1.update(plain.getBytes("UTF-8"));
// return byteToHex(sha1.digest());
// } catch (NoSuchAlgorithmException e) {
// throw new OApiResultException(e.getMessage());
// } catch (UnsupportedEncodingException e) {
// throw new OApiResultException(e.getMessage());
// }
// }
// // 字节数组转化成十六进制字符串
// private static String byteToHex(final byte[] hash) {
// Formatter formatter = new Formatter();
// for (byte b : hash) {
// formatter.format("%02x", b);
// }
// String result = formatter.toString();
// formatter.close();
// return result;
// }
let
plainTex
=
"jsapi_ticket="
+
ticket
+
"&noncestr="
+
nonce
+
"×tamp="
+
timeStamp
+
"&url="
+
url
;
//1
var
BufferList
=
new
Buffer
(
plainTex
,
"UTF-8"
);
let
signBufferList
=
cryptoJS
.
createHash
(
'sha1'
).
update
(
BufferList
).
digest
();
let
hexs
=
""
;
for
(
let
i
=
0
;
i
<
signBufferList
.
length
;
i
++
)
{
let
hex
=
(
signBufferList
[
i
]).
toString
(
16
);
if
(
hex
.
length
===
1
)
{
hexs
=
'0'
+
hex
;
}
hexs
+=
hex
.
toUpperCase
();
}
const
signature
=
hexs
;
// var BufferList = new Buffer(plainTex, "UTF-8");
// let signBufferList = cryptoJS.SHA1(BufferList).digest();
// let hexs = "";
// for (let i = 0; i < signBufferList.length; i++) {
// let hex = (signBufferList[i]).toString(16);
// if (hex.length === 1) {
// hexs = '0' + hex;
// }
// hexs += hex.toUpperCase();
// }
// const signature = hexs;
// 2
// let signature = cryptoJS.SHA1(plainTex).toString();
...
...
@@ -190,6 +158,12 @@ class UtilsUserSve extends AppServiceBase {
// let signature = cryptoJS.createHash('sha1').update(plainTex).digest('hex').toUpperCase();
//4
var
sha1
=
cryptoJS
.
createHash
(
'sha1'
);
sha1
.
update
(
plainTex
,
'utf8'
);
let
signature
=
sha1
.
digest
(
'hex'
);
this
.
logCtl
.
info
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
:
""
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment