Fix QR code creation
Change-Id: If05856a6fdafa43a93c6b57963820710db188d42
This commit is contained in:
parent
61b1580735
commit
f0e32abc4f
@ -5,23 +5,17 @@ import { PDFExport } from "@progress/kendo-react-pdf";
|
|||||||
import QRCode from "qrcode.react";
|
import QRCode from "qrcode.react";
|
||||||
|
|
||||||
function xor(a, b) {
|
function xor(a, b) {
|
||||||
var res = "",
|
var res = "";
|
||||||
i = a.length,
|
for (var i = 0; i < a.length; i++) {
|
||||||
j = b.length;
|
res += String.fromCharCode(a.charCodeAt(i) ^ b.charCodeAt(i % b.length));
|
||||||
while (i-- > 0 && j-- > 0)
|
}
|
||||||
res = (parseInt(a.charAt(i)) ^ parseInt(b.charAt(j))).toString() + res;
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateQrString(serverUrl, username, password) {
|
function calculateQrString(serverUrl, username, password) {
|
||||||
var magicString = "wo9k5tep252qxsa5yde7366kugy6c01w7oeeya9hrmpf0t7ii7";
|
const magicString = "wo9k5tep252qxsa5yde7366kugy6c01w7oeeya9hrmpf0t7ii7";
|
||||||
|
|
||||||
var urlString = "user=" + username + "&password=" + password;
|
var urlString = "user=" + username + "&password=" + password;
|
||||||
|
|
||||||
while (urlString.length > magicString.length) {
|
|
||||||
magicString += magicString;
|
|
||||||
}
|
|
||||||
|
|
||||||
urlString = xor(urlString, magicString); // xor with magic string
|
urlString = xor(urlString, magicString); // xor with magic string
|
||||||
urlString = btoa(urlString); // to base64
|
urlString = btoa(urlString); // to base64
|
||||||
|
|
||||||
@ -86,7 +80,11 @@ const ShowUserPdf = props => {
|
|||||||
var qrCode = "";
|
var qrCode = "";
|
||||||
var displayname = "";
|
var displayname = "";
|
||||||
|
|
||||||
if (props.location.state) {
|
if (
|
||||||
|
props.location.state &&
|
||||||
|
props.location.state.id &&
|
||||||
|
props.location.state.password
|
||||||
|
) {
|
||||||
const { id, password } = props.location.state;
|
const { id, password } = props.location.state;
|
||||||
|
|
||||||
const username = id.substring(1, id.indexOf(":"));
|
const username = id.substring(1, id.indexOf(":"));
|
||||||
|
Loading…
Reference in New Issue
Block a user