export function get_suffix(filename) { var pos = filename.lastIndexOf('.') var suffix = '' if (pos !== -1) { suffix = filename.substring(pos) } return suffix } export function random_string(len) { len = len || 32 var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678' var maxPos = chars.length var pwd = '' for (let i = 0; i < len; i++) { pwd += chars.charAt(Math.floor(Math.random() * maxPos)) } return pwd } export function random_filename(filename) { var suffix = get_suffix(filename) var time = new Date() var time2 = new Date('2020/01/01') return Math.ceil((time.getTime() - time2.getTime()) / 1000) + '_' + random_string(10) + suffix } export function utf8_to_b64(str) { return window.btoa(unescape(encodeURIComponent(str))) } export function b64_to_utf8(str) { return decodeURIComponent(escape(window.atob(str))) }