Skip to content

Commit

Permalink
fix: Replace atob for encod encryption in login (#3490)
Browse files Browse the repository at this point in the history
Signed-off-by: harrisonliu5 <harrisonliu@kubesphere.io>
  • Loading branch information
harrisonliu5 authored Aug 3, 2022
1 parent 7eac257 commit 52ceb5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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('')}`
}

0 comments on commit 52ceb5b

Please sign in to comment.