O
O
Oleg Kolesnikov2019-01-17 22:08:13
JavaScript
Oleg Kolesnikov, 2019-01-17 22:08:13

How to implement captcha using JWT tokens?

JWT cannot store sensitive data as it is easy to decrypt. How to store captcha data in this case? Or, for example, how to implement a rate limit bound to a token and ip?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Denis Ineshin, 2016-05-05
@IonDen

Like this: https://jsfiddle.net/IonDen/55665p35/

function prettify (num) {
    var n = num.toString();
    var separator = " ";
    return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1" + separator);
}

var $test = $(".test");
var val = $test.prop("value");
$test.prop("value", prettify(val));

A
Alexander Kshnyakin, 2016-05-07
@devpull

Another option.
Formats blur.
When changed, spaces are removed and can be adjusted.
thanks to Denis Ineshin for the regular expression.
codepen.io/alexanderkshnyakin/pen/NNorZz

D
dev-sasha, 2021-02-25
@dev-sasha

const numb = 1234567;
const numbFmt = new Intl.NumberFormat('ru-RU').format(numb);
console.log('Отформатированное число: ' + numbFmt); // 1 234 567

const numb = 1234567;
const numbFmt = numb.toLocaleString('ru-RU');
console.log('Отформатированное число: ' + numbFmt);  // 1 234 567

B
Belokobylsky, 2022-03-31
@belokobylsky

The previous methods don't work well for very large numbers, so here's mine:

console.log(
"498065392975507667366026341067548906436328316841307936116457316164193184705285250962660148627300967657213217328759941177315742017903027130095729437206958025287403606910196074469378649164695055964366281024547871829070617652494336"
  .split("")
  .reverse()
  .join("")
  .replace(/\d\d\d/g, "$& ")
  .split("")
  .reverse()
  .join("")
);

I
Ivan Shumov, 2019-01-17
@inoise

On server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question