Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Replace atob for encod encryption in login #3490

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/containers/Login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ import {

import { get } from 'lodash'

import { Base64 } from 'js-base64'
import styles from './index.scss'

function encrypt(salt, str) {
return mix(salt, window.btoa(str))
return mix(salt, Base64.encode(str))
}

function mix(salt, str) {
Expand All @@ -49,8 +50,7 @@ function mix(salt, str) {
prefix.push(sum % 2 === 0 ? '0' : '1')
ret.push(String.fromCharCode(Math.floor(sum / 2)))
}

return `${window.btoa(prefix.join(''))}@${ret.join('')}`
return `${Base64.encode(prefix.join(''))}@${ret.join('')}`
}

@inject('rootStore')
Expand Down
6 changes: 3 additions & 3 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import {
import generate from 'nanoid/generate'
import moment from 'moment-mini'

import { Base64 } from 'js-base64'
import { PATTERN_LABEL, MODULE_KIND_MAP } from './constants'

/**
* format size, output the value with unit
* @param {Number} size - the number need to be format
Expand Down Expand Up @@ -748,7 +748,7 @@ export const inCluster2Default = name => {
}

export const encrypt = (salt, str) => {
return mix(salt, window.btoa(str))
return mix(salt, Base64.encode(str))
}

function mix(salt, str) {
Expand All @@ -765,5 +765,5 @@ function mix(salt, str) {
ret.push(String.fromCharCode(Math.floor(sum / 2)))
}

return `${window.btoa(prefix.join(''))}@${ret.join('')}`
return `${Base64.encode(prefix.join(''))}@${ret.join('')}`
}