Dear All @brainstorrrm @yisrael-wix @givemeawhisky
I have been writing my own captcha code that is run server side, what I am trying to do is now create an image out of the below “return data” and then return the image to client side with the returned data.
I can get the returned data to client side but that is missing the point, I feel as the data would then be available client side for malitious individuals or computers to read and would then make the captcha worthless?
I am sure there is a way in the backend to create an image out of the data as I have created SVG QRCodes in the back but this was using the qrCode module, If you could help in anyway of how to convert the data to an image and return the image to client side that would be greatly appreciated.
I also have a way of checking the code on server side but need to know how to utilise the returned data from the below function and use this in the check function? if that is possible?
Best regards
Si
export function createCaptcha() {
let captcha = "";
var length = 20;
var possible = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ@!#$%^&*";
for (var i = 0; i < length; i++)
captcha += possible.charAt(Math.floor(Math.random() * possible.length))
var a = captcha.split('');
var l = a.length;
var i = 0;
var h = {};
var v = "";
while (i < l) {
h[a[i]] = (h[a[i]] || 0) + 1;
i += 1;
}
for (var c in h) {
if (h[c] === 1) {
v += c;
}
}
var str = v;
var A = str.slice(1, 2);
var B = str.slice(2, 3);
var C = str.slice(3, 4);
var D = str.slice(4, 5);
var E = str.slice(5, 6);
var F = str.slice(6, 7);
var string = A + B + C + D + E + F;
let rgb = "";
var r = Math.floor(Math.random() * 255);
var g = Math.floor(Math.random() * 255);
var b = Math.floor(Math.random() * 255);
rgb = 'rgb(' + r + ', ' + g + ' , ' + b + ')';
var data = {
numberOne: A,
numberTwo: B,
numberThree: C,
numberFour: D,
numberFive: E,
numberSix: F,
code: string,
colour: rgb
};
return data;
}