binary
This tag converts ascii to binary
Created by: hackvertor
Installed 1 times
Category: Convert
Created on: Tuesday, September 24, 2024 at 11:32:39 AM
Updated on: Friday, December 20, 2024 at 8:07:49 PM
Tag arguments
[]
Code
class binary {
encode(input) {
return input.split('').map(chr => chr.codePointAt(0).toString(2).padStart(8, "0")).join(' ')
}
decode(input) {
return input.split(" ").map(bin => String.fromCodePoint(parseInt(bin,2))).join('')
}
matches(input) {
return /^(?:(?:[10]){8}\s?)+/.exec(input);
}
}