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: Friday, December 20, 2024 at 8:06:04 PM
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);
}
}