Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function plaintext = decrypt(ciphertext, key)
- key = lower(key) - double('a') + 1;
- key(key < 0) = 27;
- ciphertext = lower(ciphertext) - double('a') + 1;
- ciphertext(ciphertext < 0) = 27;
- keyIndex = mod(0:(numel(ciphertext)-1), numel(key))+1;
- k = key(keyIndex);
- plaintext = arrayfun(@(m,n) find(v(m,:) == n), k, ciphertext) - 1;
- plaintext(plaintext == 26) = double(' ') - double('a');
- plaintext = upper(char(plaintext + double('a')))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement