Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
identification division.
program-id. otp.
environment division.
input-output section.
select key-file assign to 'key.txt'
organization line sequential.
data division.
file section.
fd key-file.
01 key-data pic x(50).
working-storage section.
01 ws-flag pic x(1).
01 ws-key pic x(50).
01 ws-parse.
05 ws-parse-data pic S9(9).
01 ws-xor-len pic 9(1) value 1.
77 ws-ctr pic 9(1).
procedure division.
open input key-file.
read key-file into ws-key end-read.
display 'Enter your message to encrypt:'.
move 1 to ws-ctr.
perform 50 times
call 'getchar' end-call
move return-code to ws-parse
move ws-parse to ws-flag
call 'CBL_XOR' using ws-key(ws-ctr:1) ws-flag by value
ws-xor-len end-call
display ws-flag with no advancing
add 1 to ws-ctr end-add
close key-file.
end program otp.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment