RosettaCodeData/Task/Vigen-re-cipher/Smalltalk/vigen-re-cipher-1.st

4 lines
321 B
Smalltalk
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
prep := [:s | s select:[:ch | ch isLetter] thenCollect:[:ch | ch asUppercase]].
encrypt := [:s :cypher | (prep value:s) keysAndValuesCollect:[:i :ch | ch rot:((cypher at:((i-1)\\key size+1))-$A) ]].
decrypt := [:s :cypher | (prep value:s) keysAndValuesCollect:[:i :ch | ch rot:26-((cypher at:((i-1)\\key size+1))-$A) ]].