Sha256: b7e0d0861c7cfa25b141b870d32052054604c0a1e2207169d9315676013d77ae
Contents?: true
Size: 408 Bytes
Versions: 117
Compression:
Stored size: 408 Bytes
Contents
class RotationalCipher { static rotate(text, shift) { return [...text].map((c) => { const isUpper = c.match(/[A-Z]/); const isAlpha = c.match(/[a-z]/i); const charShift = (isUpper ? 'A' : 'a').charCodeAt(0); return isAlpha ? String.fromCharCode((((c.charCodeAt(0) - charShift) + shift) % 26) + charShift) : c; }).join(''); } } export default RotationalCipher;
Version data entries
117 entries across 117 versions & 1 rubygems