Sha256: eeff80c0878c8e0f1f0125a6cfb894d0050c8767d1d8007cb435369ea8b83689
Contents?: true
Size: 1.32 KB
Versions: 207
Compression:
Stored size: 1.32 KB
Contents
import Foundation struct Atbash { private static func stripWhiteSpaceAndPunctuations(_ input: String) -> String { var returnString = "" input.characters.forEach { if !" ,.".contains(String($0)) { returnString.append($0) } } return returnString } static let cipherDictApply: [Character : Character] = ["a": "z", "b": "y", "c": "x", "d": "w", "e": "v", "f": "u", "g": "t", "h": "s", "i": "r", "j": "q", "k": "p", "l": "o", "m": "n", "n": "m", "o": "l", "p": "k", "q": "j", "r": "i", "s": "h", "t": "g", "u": "f", "v": "e", "w": "d", "x": "c", "y": "b", "z": "a"] static func encode( _ valueIn: String) -> String { let value = stripWhiteSpaceAndPunctuations(valueIn.lowercased() ) var text2return = "" for each in value.characters { text2return.append(cipherDictApply[each] ?? each ) } return insertSpace5th(text2return) } static func insertSpace5th(_ value: String) -> String { var tempCounter = 0 var tempString: String = "" for each in value.characters { if tempCounter % 5 == 0 && tempCounter != 0 { tempString += " \(each)" } else { tempString += "\(each)" } tempCounter += 1 } return tempString } }
Version data entries
207 entries across 207 versions & 1 rubygems