首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
CSC 172代写、Java/C++程序设计代做
项目预算:
开发周期:
发布时间:
要求地区:
CSC 172 – Project 1
• You may work on and submit your project individually or in groups of 2 students.
• If you work in a group you will have to prepare an extended README file to specify
who wrote each part of the code for maintaining clarity and transparency within the
group project.
• You are only allowed to cooperate with your group members, and you are not permitted
to share your solution with other students in any way.
Task
You will implement a cipher specified below using Java programming language. It shall
encrypt/decrypt text files including plaintext/ciphertext.
Background
1. Encryption is the process of encoding information or data in such a way that only
authorized parties can access it. This is typically done using algorithms and secret
keys to transform the original data into an unintelligible form known as ciphertext.
2. Plaintext refers to the original, unencrypted data or message that is intended to be
kept confidential.
3. Ciphertext refers to the encrypted form of data or information that has undergone
encryption.
Working with files
To encrypt content of a text file you have to:
• Read the file: open the file you want to encrypt and read its contents into memory.
• Convert to binary.
• Encrypt the data: use the presented encryption algorithm and the user secret key to
encrypt the data read from the file.
• Do NOT convert back to characters.
• Write encrypted data to file: save the encrypted data to a new file.
To decrypt content of a text file you have to:
1
• Read the file: open the file you want to decrypt and read its contents into memory
(content should be just long sequence of zeros and ones).
• Decrypt the data: use the presented decryption algorithm and the user secret key to
encrypt the data read from the file.
• Convert to characters.
• Write decrypted data to file: save the encrypted data to a new file.
1 Algorithm Description
The algorithm encrypts fixed number of bits only (64 bits). To encrypt longer input use the
simple ECB (Electronic Codebook) mode. Here’s how it works:
• Divide the data into blocks: the plaintext data is divided into fixed-size blocks of 64
bits.
• Apply encryption to each block independently: each block of plaintext is encrypted
independently using the same secret key and encryption algorithm. The same key is
used for each block.
• Output the encrypted blocks: the resulting ciphertext blocks are concatenated together
to form the complete ciphertext.
• If the last block doesn’t have enough bits, it needs to be padded to meet the required
block size. This process is known as padding. Use zero padding: append zero bits
to the end of the block until it reaches the required size. (Do not worry about extra
characters at the end when you decrypt.)
Include methods to encrypt/decrypt a single block of plaintext/ciphertext that implements the following symmetric-key encryption algorithm:
2
Your output shall be a block of 64 zeros and ones. (Do not represent the output block in a
Hex notation. If you do that you get -10%.) Encryption and decryption are almost the
same, but for decryption you need to use subkeys in a reverse order: k10, k9, ...k1
3
1. Input Splitting: The plaintext block of 64 bits is divided into two halves of 32 bits.
Let’s denote these halves as L0 and R0.
2. Round Function Application: In each round, a round function f is applied to one
half of the data, typically the right half Ri
, using the round key ki of 32 bits. The
result of the function is then XORed with the other half Li
.
Li+1 = Ri
Ri+1 = Li ⊕ f(Ri
, ki)
3. Swapping: After each round, the halves are swapped so that the left half becomes
the right half, and vice versa.
4. Iteration: Steps 2 and 3 are repeated 10 times.
5. Output Concatenation: After all rounds are completed, the final output consists of
the two halves (L10 and R10) concatenated together. This forms the ciphertext.
1.1 The f - function
The f - function (round function) works as follows:
1. XOR gate: The 32 input bits are XORed with the round key ki
.
2. Splitting: The 32 bits are divided into four pieces of 8 bits.
4
3. S-box: For each piece of 8 bits the output of a S-box is computed (’looked up in the
S table’).
4. Output Concatenation: All four pieces are concatenated together to form 32 bits.
5. Permutation: 32 bits are permuted using permutation P.
S is a substitution box transformation (Rijndael S-box):
The table of the S-box, stated in hexadecimal for compactness. Permutation P is given by
the table:
See the last page if clarification about S and P is needed.
5
1.2 Computing subkeys
The round keys of 32 bits (subkeys ki) are derived from the input key of 56 bits by means
of the key schedule (total of 10 subkeys) using the following schedule:
1. Splitting: The main key k of 56 bits is divided into two halves of 28 bits. Let’s denote
these halves as C0 and D0.
2. Transformation Function: In each round, a left shift by 1 function LS1 is applied
separately to both half’s of the data, typically the right half Ri
, using the round key
ki of 32 bits. The result of the function is then XORed with the other half Li
.
Ci+1 = LS1(Ci)
Di+1 = LS1(Di)
3. Concatenation: In each round two halves (Ci and Di) are concatenated together.
The first (left most) 32 bits forms the round subkey ki
.
4. Iteration: Steps 2 and 3 are repeated 10 times.
6
1.3 Required methods
Your implementation must include the following methods:
• Custom xorIt(binary1, binary2)
• Custom shiftIt(binaryInput)
• Custom permuteIt(binaryInput)
• Custom SubstitutionS(binaryInput)
• functionF(rightHalf, subkey)
• encryptBlock(block, inputKey),
• decryptBlock(block, inputKey),
• encryption(longBinaryInput, inputKey),
• decryption(longBinaryInput, inputKey),
• keyScheduleTransform(inputKey),
• runTests()
• You can have additional helper functions. Custom means you can NOT use
ready methods and must write your own methods.
1.4 Build-in tests
The runTests() mathod shall be invoked when user runs the program and it shall print
output for the following test cases:
• encryptBloc(all ones, all ones)
• encryptBloc(all zeros, all ones)
• encryptBloc(all zeros, zeros)
• encryptBloc(block,input key), where:
block = 1100110010000000000001110101111100010001100101111010001001001100
input key = all zeros
• decryptBlock(all ones, all ones)
• decryptBlock(all zeros, all ones)
7
• decryptBlock(all zeros, zeros)
• decryptBlock(block,input key), where:
block = 0101011010001110111001000111100001001110010001100110000011110101
input key = all ones
• decryptBlock(block,input key), where:
block = 0011000101110111011100100101001001001101011010100110011111010111
input key = all zeros
When running the program
When the user runs the program, it should print output for the test cases from section 1.4.
The program should then prompt the user to choose whether they want to encrypt or decrypt
and specify the filename to process. Additionally, the program should ask for a filename to
save the output, and an appropriate file should be created for this purpose.
Running Tests:
Output for: encryption(all ones, all ones)
0101011010001110111001000111100001001110010001100110000011110101
Output for: encryption(all zeros, all ones)
1100111010001000100011011010110110110010100101011001100000101000
Output for: encryption(all zeros, all zeros)
1010100101110001000110111000011110110001101110011001111100001010
Output for: encryption(block,all zeros), where:
block = 1100110010000000000001110101111100010001100101111010001001001100
0010101110011011010001010111000010110110101011111010000101100101
Output for: decryption(all ones, all ones)
0100111001000110011000001111010101010110100011101110010001111000
Output for: decryption(all zeros, all ones)
1011001010010101100110000010100011001110100010001000110110101101
Output for: decryption(all zeros, all zeros)
1011000110111001100111110000101010101001011100010001101110000111
Output for: decryption(block,all ones), where:
block = 0101011010001110111001000111100001001110010001100110000011110101
1111111111111111111111111111111111111111111111111111111111111111
Output for: decryption(block,all zeros), where:
block = 0011000101110111011100100101001001001101011010100110011111010111
1111111111111111111111111111111111111111111111111111111111111111
Do you want to encrypt or decrypt (E/D): E
Filename: data.txt
Secret key: 10101101011101110101010101011100010110101011100010101010
8
Output file: data1.txt
Submission Requirements
Zip (archive) all the project source files and a README file and save it as a Project1LastName.zip
file. Include your LastName (+partner) in the filename. Upload the file to the appropriate
folder on Gradescope. Your README file should include name of the members of the team
and any specific instruction which is useful for the project. It should also include all the features (including additional features) that you have implemented. Make sure all your source
files are properly commented so that user can browse your code without getting lost.
2 Grading
The rubric for this assignment is available through Gradescope. Your solution will be tested
with private test cases.
0 points if the program doesn’t compile. No points for the rest. Grading complete.
2.1 Important note about Academic Honesty
If some of the tasks are challenging or not for you, feel free to discuss with others but all
discussion have to be on high level without writing code or pseudocode. Once you sit down
and start coding, all the code you write should be your own . Using ready code from other
sources (internet, friends, chatGPT etc.) will be considered as a violation of the academic
honesty. After submitting your work, you should be able to explain your code in details, if
so requested by lab TAs or by the instructor. Your initial points may be reduced, if unable
to answer questions on your submitted work.
3 Hints
• Text file sbox.txt contains a constant - S- box look up table that you can use.
• S- box example:
– Let’s say we want to compute the substitution for the byte 53 (in binary 01010011).
– We’ll first convert 53 to its row and column indices.
– The first hex digit (5) represents the row index.
– The second hex digit (3) represents the column index.
– So, for 53, the row index is 5 and the column index is 3.
– Now, we’ll look up the value in the S-box using these indices.
9
– The value at row 5 and column 3 in the S-Box is ed (in binary 11101101).
• Permutation table example: Consider table (3x3):
Sample input: 101111000
Output after permutation: 001111010
– The permutation table rearranges the elements of the input according to the
specified positions.
– Each number in the permutation table represents the position of the corresponding
element in the input.
– For example, the element at position 1 of the input (value 1) becomes the element
at position 4 of the output.
– Similarly, the element at position 9 of the input (value 0) becomes the element at
position 1 of the output.
Sample input 2: 111000111
Output after permutation 2: 111100101
10
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!