Vigenère cipher: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
m (→{{header|J}}) |
||
Line 1,583: | Line 1,583: | ||
'''Solution:'''<br> |
'''Solution:'''<br> |
||
Using [https://github.com/jsoftware/convert_misc/blob/master/vig.ijs <code>vig</code>] from the [[j:Addons/convert/misc/vig|convert/misc/vig addon]]: |
Using [https://github.com/jsoftware/convert_misc/blob/master/vig.ijs <code>vig</code>] from the [[j:Addons/convert/misc/vig|convert/misc/vig addon]]: |
||
⚫ | |||
<lang j>NB.*vig c Vigenère cipher |
|||
NB. cipher=. key 0 vig charset plain |
|||
NB. plain=. key 1 vig charset cipher |
|||
vig=: conjunction define |
|||
: |
|||
r=. (#y) $ n i.x |
|||
n {~ (#n) | (r*_1^m) + n i.y |
|||
) |
|||
⚫ | |||
preprocess=: (#~ e.&ALPHA)@toupper NB. force uppercase and discard non-alpha chars |
preprocess=: (#~ e.&ALPHA)@toupper NB. force uppercase and discard non-alpha chars |
||
vigEncryptRC=: 0 vig ALPHA preprocess |
vigEncryptRC=: 0 vig ALPHA preprocess |