CONVERT THE FOLLOWING FUNCTION IN MARS SIMULATOR (MIPS)
This FUNCTION should be Runnable on MARS (MIPS Assembler and Runtime Simulator) IDE
C FUNCTION WHICH NEEDS TO BE CONVERTED (ONLY USE MARS)
void decrypt(int numberOfChar, int key, char * cipherText, char * plainText)
{
int j = 0;
int i =0;
int k = 0;
int reverseOrderedKey[4];
int n =4;
int c =0;
int d =0;
int orderedKey[4] = {0,0,0,0};
while(key)
{
reverseOrderedKey[k] = key %10;
key /= 10;
k++;
}
for (c = n - 1, d = 0; c >= 0; c--, d++)
orderedKey[d] = reverseOrderedKey[c];
for ( j=0; j <= 4; j++)
{
for( i=0; i<numberOfChar; i++)
{{
plainText[i] = cipherText[i] - orderedKey[j];
}
j += 1;
if (j %4 == 0) j = 0;
}
if (i == strlen(cipherText)) break;
}
}
.file 1 ""
.section .mdebug.abi32
.previous
.nan legacy
.module fp=32
.module nooddspreg
.abicalls
.text
.align 2
.globl decrypt
.set nomips16
.set nomicromips
.ent decrypt
.type decrypt, @function
decrypt:
.frame $sp,88,$31 # vars= 32, regs= 8/0, args= 16, gp= 8
.mask 0x807f0000,-4
.fmask 0x00000000,0
.set noreorder
.cpload $25
.set nomacro
addiu $sp,$sp,-88
.cprestore 16
sw $21,76($sp)
sw $20,72($sp)
sw $17,60($sp)
movz $31,$31,$0
sw $31,84($sp)
sw $22,80($sp)
sw $19,68($sp)
sw $18,64($sp)
sw $16,56($sp)
move $20,$4
move $21,$6
beq $5,$0,$L4
move $17,$7
li $2,10 # 0xa
bne $2,$0,1f
div $0,$5,$2
break 7
1:
mfhi $3
mflo $4
beq $4,$0,$L4
sw $3,40($sp)
li $3,100 # 0x64
bne $2,$0,1f
div $0,$4,$2
break 7
1:
mfhi $4
nop
nop
bne $3,$0,1f
div $0,$5,$3
break 7
1:
mflo $3
beq $3,$0,$L4
sw $4,44($sp)
li $4,1000 # 0x3e8
bne $2,$0,1f
div $0,$3,$2
break 7
1:
mfhi $3
nop
nop
bne $4,$0,1f
div $0,$5,$4
break 7
1:
mflo $5
beq $5,$0,$L4
sw $3,48($sp)
bne $2,$0,1f
div $0,$5,$2
break 7
1:
mfhi $5
sw $5,52($sp)
$L4:
lw $2,52($sp)
move $16,$0
sw $2,24($sp)
lw $2,48($sp)
addu $19,$21,$20
sw $2,28($sp)
lw $2,44($sp)
addiu $18,$sp,24
sw $2,32($sp)
lw $2,40($sp)
nop
sw $2,36($sp)
$L3:
blez $20,$L10
move $22,$0
move $2,$21
move $5,$17
$L7:
sll $4,$16,2
addu $4,$18,$4
lbu $3,0($2)
lw $4,0($4)
addiu $16,$16,1
subu $3,$3,$4
andi $4,$16,0x3
bne $4,$0,$L6
sb $3,0($5)
move $16,$0
$L6:
addiu $2,$2,1
bne $19,$2,$L7
addiu $5,$5,1
move $22,$20
$L10:
lw $25,%call16(strlen)($28)
nop
.reloc 1f,R_MIPS_JALR,strlen
1: jalr $25
move $4,$21
lw $28,16($sp)
beq $2,$22,$L1
addiu $16,$16,1
slt $2,$16,5
bne $2,$0,$L3
nop
$L1:
lw $31,84($sp)
lw $22,80($sp)
lw $21,76($sp)
lw $20,72($sp)
lw $19,68($sp)
lw $18,64($sp)
lw $17,60($sp)
lw $16,56($sp)
j $31
addiu $sp,$sp,88
.set macro
.set reorder
.end decrypt
.size decrypt, .-decrypt
.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609"
CONVERT THE FOLLOWING FUNCTION IN MARS SIMULATOR (MIPS) This FUNCTION should be Runnable on MARS (MIPS...
This code should be Runnable on MARS (MIPS Assembler and Runtime Simulator) IDE Convert the following c code into mips #include <stdio.h> #include <string.h> char cipherText[200] = "anything"; int countNumberOfCharInCipher(char*); int countNumberOfCharInCipher(char* cText) { return strlen(cText); } int countSpaces(int numberOfChar, char input[]) { int spaceCounter =0; for(int i=0; i < numberOfChar; i++) { if(input[i] == 32) spaceCounter++; } return spaceCounter; } void decrypt(int numberOfChar, int key, char * cipherText, char * plainText) { int j = 0; int i =0;...
Caesar Cipher v3 Decription Description A Caesar cipher is one of the first and most simple encryption methods. It works by shifting all letters in the original message (plaintext) by a certain fixed amount (the amounts represents the encryption key). The resulting encoded text is called ciphertext. Example Key (Shift): 3 Plaintext: Abc Ciphertext: Def Task Your goal is to implement a Caesar cipher program that receives the key and an encrypted paragraph (with uppercase and lowercase letters, punctuations, and...
Question: Please Provide Comments on each Line of code explaining what the C Function is doing throughout the code. // Function used for substitution encryption void SubEncrypt(char *message, char *encryptKey) { int iteration = 0; printf("Enter Aphabet Encryption Key: \n"); scanf("%s", encryptKey); for (iteration = 0; iteration < strlen(message); iteration++) { char letter = message[iteration]; if (letter >= 'A' && letter <= 'Z') { letter = encryptKey[letter - 'A']; } message[iteration] = letter; } printf("CipherText message: %s\n", message); } //_________________________________________________________________________________________________________________________________________________...
Change the following Shift Cipher program so that it uses OOP(constructor, ect.) import java.util.*; import java.lang.*; /** * * @author STEP */ public class ShiftCipher { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner(System.in); String plainText; System.out.print("Please enter your string: "); // get message plainText = input.nextLine(); System.out.print("Please enter your shift cipher key: "); // get s int s = input.nextInt(); int...
C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...
C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...
Objective Create a MIPS program in Mars to perform a sorting algorithm. Specification: 1) Download the file Assign2.asm. Read it and make sure it can be compiled and executed in Mars. 2) Write code to finish all the tasks listed in Assign2.asm. In Assign2.asm, an array‘a’ of ‘n’=11 integers are given at the beginning (make sure do not change these integers): 43, -5, 11, 12, 64, -7, 14, 71, 70, 13, -27 The finished Assign2.asm should be filled with your...
Study the VIGENÈRE CIPHER and implemented it with c++ 1.In your program, you should have two functions: encryption and decryption. 2. Use any key you like. (Don't use deceptive in the slides) 3. choose a sentence or a paragraph you like as the plaintext. I have the code I just need the implementation in a different way // C++ code to implement Vigenere Cipher #include<bits/stdc++.h> using namespace std; // This function generates the key in // a cyclic manner until...
Write helpful comments for the
following code: use Vigenere cipher tech to encrypt and decrypt
message
The code:
#include<stdio.h>
#include <stdlib.h>
char arr[26][26];
char message[22], key[22], emessage[22], retMessage[22];
int findRow(char);
int findColumn(char);
int findDecRow(char, int);
int main()
{
int i = 0, j, k, r, c;
k = 96;
for (i = 0; i<26; i++)
{
k++;
for (j = 0; j<26; j++)
{
arr[i][j] = k++;
if (k == 123)
k = 97;
}
}
printf("\nEnter message\n");
fgets(message, 22,...
LANGUAGE: PYTHON
Write a function called: d_polybius(). The
function applies the decryption scheme for the polybius cipher
scheme above. The start of the function call the
get_polybius_square function to get the square as a
string.
The second scenario when the number of characters is not even,
excluding ‘\n’. For instance: “71\n5” is an invalid cipher because
there is no way that the last number correspond to a character (we
need two numbers).
A customized version of Polybius square will be...