Write a program in NASM that performs simple encryption by r
Write a program in NASM that performs simple encryption by rotating each plaintext byte a varying number of positions in different directions. For example, in the following array that represents the encryption key, a negative value indicates a rotation to the left and a positive value indicates a rotation to the right. The integer in each position indicates the magnitude of the rotation:
key BYTE -2, 4, 1, 0, -3, 5, 2, -4, -4, 6
Your program should loop through a plaintext message and align the key to the first 10 bytes of the message. Rotate each plaintext byte by the amount indicated by its matching key array value. Then, align the key to the next 10 bytes of the message and repeat the process. (A VideoNote for this exercise is posted on the Web site.)
Can you please include screenshots or any pic of running program
Write a program in NASM that performs simple encryption by rotating each plaintext byte a varying number of positions in different directions. For example, in the following array that represents the encryption key, a negative value indicates a rotation to the left and a positive value indicates a rotation to the right. The integer in each position indicates the magnitude of the rotation:
key BYTE -2, 4, 1, 0, -3, 5, 2, -4, -4, 6
Your program should loop through a plaintext message and align the key to the first 10 bytes of the message. Rotate each plaintext byte by the amount indicated by its matching key array value. Then, align the key to the next 10 bytes of the message and repeat the process. (A VideoNote for this exercise is posted on the Web site.)
Can you please include screenshots or any pic of running program
key BYTE -2, 4, 1, 0, -3, 5, 2, -4, -4, 6
Your program should loop through a plaintext message and align the key to the first 10 bytes of the message. Rotate each plaintext byte by the amount indicated by its matching key array value. Then, align the key to the next 10 bytes of the message and repeat the process. (A VideoNote for this exercise is posted on the Web site.)
Can you please include screenshots or any pic of running program
Solution
SECTION .data
msg db\"Hello\", 0
key db -2, 4, 1, 0, -3, 5, 2, -4, -4, 6
SECTIO .code
main proc
mov ecx, LENGTHOF key
mov edx, OFFSET msg
mov esi, OFFSET key
mov ebx, 0
top:
cmp [ebx], esi
jl ShiftLeft
cmp [ebx], esi
jg ShiftRight
cmp [ebx], esi
je NoShift
ShiftLeft:
mov cl, [esi]
SHL edx, cl
add esi, TYPE key
inc edx
L1 top
ShiftRight:
mov cl, [esi]
SHR edx, cl
add esi, TYPE key
L1 top
NoShift:
add esi, TYPE key
L1 top
call WriteString
invoke ExitProcess,0
main endp
end main

