parent
eb85cf815f
commit
a3015b8f92
8 changed files with 114 additions and 85 deletions
@ -1,15 +1,41 @@ |
||||
/** |
||||
* 阿里云oss配置 |
||||
* */ |
||||
import { get } from '@/utils/http' |
||||
import api from '@/utils/api' |
||||
import CryptoJS from 'crypto-js' |
||||
import JSEncrypt from 'jsencrypt' |
||||
|
||||
export default { |
||||
// oss账号信息
|
||||
config: { |
||||
region: 'oss-cn-shenzhen', |
||||
accessKeyId: 'LTAI4FzqQHnk4rozqLZ8jCNj', |
||||
accessKeySecret: 'mveW7B1OyFoKUkHm8WsxmrjHmkJWHq', |
||||
bucket: 'huoran' |
||||
}, |
||||
// 上传成功url前置部分(成功回调没有返回url)
|
||||
preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' |
||||
const A = (key, encryptedData) => { |
||||
const keyHex = CryptoJS.enc.Base64.parse(key) |
||||
const decrypted = CryptoJS.AES.decrypt(encryptedData, keyHex, { |
||||
mode: CryptoJS.mode.ECB, |
||||
padding: CryptoJS.pad.Pkcs7 |
||||
}) |
||||
return decrypted.toString(CryptoJS.enc.Utf8) |
||||
} |
||||
|
||||
const R = (encryptedKey, privateKey) => { |
||||
const decrypt = new JSEncrypt() |
||||
decrypt.setPrivateKey(privateKey) |
||||
const decryptedKey = decrypt.decrypt(encryptedKey) |
||||
return decryptedKey |
||||
} |
||||
|
||||
export default async function () { |
||||
try { |
||||
const res = await get(api.encrypt) |
||||
const RE = A(R(res.encryptedKey, res.privateKey), res.encryptedData).split('/') |
||||
return { |
||||
// oss账号信息
|
||||
config: { |
||||
region: 'oss-cn-shenzhen', |
||||
accessKeyId: RE[0], |
||||
accessKeySecret: RE[1], |
||||
bucket: 'huoran' |
||||
}, |
||||
// 上传成功url前置部分(成功回调没有返回url)
|
||||
preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' |
||||
} |
||||
} catch (e) { } |
||||
} |
Loading…
Reference in new issue