Sha256: e9c5722bc3dd7d533d966ed94fd4ed7b1cc1338d9330514e1138d32d4b38c271
Contents?: true
Size: 748 Bytes
Versions: 118
Compression:
Stored size: 748 Bytes
Contents
struct RotationalCipher { static func rotate(_ target: String, ROT: Int) -> String { var result = "" target.unicodeScalars.forEach { unicode in switch unicode.value { case 65...90: // A to Z var scalar = unicode.value + UInt32(ROT) if scalar > 90 { scalar -= 26 } result.append(Character(UnicodeScalar(scalar)!)) case 97...122: // a to z var scalar = unicode.value + UInt32(ROT) if scalar > 122 { scalar -= 26 } result.append(Character(UnicodeScalar(scalar)!)) default: result.append(Character(unicode)) } } return result } }
Version data entries
118 entries across 118 versions & 1 rubygems