encodedWord
Encodes and decode encoded word.
Created by: hackvertor
Installed 2 times
Category: Convert
Created on: Tuesday, September 17, 2024 at 12:22:26 PM
Updated on: Sunday, September 22, 2024 at 7:25:18 AM
Tag arguments
[]
Code
class encodedWord {
encode(input) {
return input.split('').map(chr => '=' + chr.codePointAt().toString(16).padStart(2, '0')).join('')
}
decode(input) {
return input.replaceAll(/=[a-fA-F0-9]{2}/gi, function(hex){
return String.fromCodePoint(parseInt(hex.replaceAll("=",""),16));
});
}
matches(input) {
return /^(=[a-fA-F0-9]{2})+/.exec(input);
}
}