Assignment Implement A QR Payment Support Tool (Version v1.1)
Assignment Implement A QR Payment Support Tool (Version v1.1)
ASSIGNMENT
Implement a QR payment support tool
(Version v1.1)
1. Introduction
Nowadays, the payment trend in the economy is shifting towards using methods of non-
cash payment. These methods bring many advantages to bank users:
- No need to keep large amounts of cash: Non-cash payment users will not be anxious
about being robbed, counterfeit money or fire incidents.
- No need to meet face to face: Cashless payment users will save travel time to meet,
thereby enhancing their productivity or giving them more free time.
- Transaction information is stored: When using cash payment, people who need to
manage expenses casually have to record their spending on paper forms like receipts
or notes. This way of expenses management may be hard to track and time-consuming.
On the other hand, cashless payment stores all people’s transactions in detail and
automatically. Thereby, the need to review their transactions can be conducted at any
time.
- Get interest from the bank: Idle money in the account can be used to save money in
the bank and bring extra income (interest) to the user.
Realizing the above benefits, banks began to race with technologies to support cashless
payment. E-banking and mobile banking are the iconic services that initiate the movement of
cashless payment. In these services, the payment can be established by entering the recipient's
account number and bank name. Afterward, the bank system will check the above information
and confirm whether the input is matched with the correct person/account in the bank. If the
input is confirmed, the remitter continues to enter the amount of money to transfer and the
message (if any) to the recipient.
Thanks to the National Payment Gateway Service from NAPAS1, all interbank transactions
are instantaneous, just like paying cash. However, when it comes to in-person payments (such
as payments at cashier counters in stores or supermarkets), online payments still have it own
limitations. First of all, the sender needs to know the recipient’s correct account number, which
is often a long and difficult number to remember. In addition, the sender can enter this number
incorrectly, which results in laborious efforts for the sender to retry. In some cases, if the sender
is careless, his/her money can be sent to wrong person!
Perhaps, there still exists a solution that can further improve the above method in terms of
interaction. This solution also allows users to make interbank, cashless payments easỉer, faster
and with less error user input. And now that solution can achieved by using QR code scanning
application, so called QR payment.
1
The National Payment Corporation of Vietnam - NAPAS
This solution can be applied to small convenience stores when dealing with customers and
minimizing contact. Subsequently, it is possible to reduce the risk of spreading the epidemic
of the current COVID-19 pandemic. At the sametime, for people, especially in Ho Chi Minh
City and southern provinces, shopping and payment will take place in a safer way. The
distribution environment will not be congested, difficult; and reduce the overall economic loss
of the localities.
Within the scope of this Assignment, each student needs to implement a tool to support QR
payments, more specifically, interbank payments. This tool will read the QR codes of given
banks (the format of will also be given) and return the information of recipient as well as allow
interbank transfers.
2. Requirements
In this Assignment, student needs to implement a C program to simulate a simple QR
payment support tool. In particular, this program will read some user inputs (number or string)
from the keyboard, which is the message of QR code. Then, the program will process and print
to the screen the results obtained from the execution process.
3. Program Specifications
The input data will consist of many lines, in which the first line is used to indentìy the
function (Menu_code). The followings lines are values that is used to run that function
The format of the first line will look like this:
Menu_code
<Line 2>
…
1
<Message of the QR code>
In which:
- Bank name, Account number, and Account holder name will be printed as described
in Section 4.
- Creation time will be printed with format dd/mm/yyyy (e.g., 19/02/2022).
Note that:
- If Creation time extracted from a message has only the last 2 digits of the year (refers
to Section 4.3), then when printing to the screen, the first 2 digits of the year will be
20. For instance, if Creation time in message is “220821”, the program prints to the
screen 21/08/2022.
- There should be a blank space right after each colon (“:”)
- All QR messages entered are valid messages. Student should not care about invalid QR
messages.
Example 1
Input 1
00020101021BKB0271001142475TranMinhHoang22082021
Example 2
Input 1
0002010102108162021KHB012100002512112DangVu
Example 3
Input 1
00020101021TrinhThiKhanhDuyen29136412200101HBB
2
<Bank to convert to>
<Message of QR code>
In which:
- Bank to convert to: Is 1 of 3 following strings: “BKB”, “KHB”, “HBB”
Note that:
- If the Bank to convert to does not match 1 of the 3 strings mentioned above, the
program prints out "Invalid bank to convert to" and terminates the program.
Example 4
Input 2
KHB
00020101021BKB0271001142475TranMinhHoang22082021
Output 0002010102108222021BKB0271001142475TranMinhHoang
Example 5
Input 2
HBB
0002010102107312021KHB013900001913490NguyenThinhToan
Output 00020101021NguyenThinhToan013900001913490210731KHB
Example 6
Input 2
VCB
00020101021HuynhNgocPhu14226317200706HBB
3
<Account holder name mode> <Account number mode> <QR message mode>
< Message of QR code >
In which:
- Account holder name mode: can be 0, 1 or 2. Refer to section 7.4.
- Account number mode: can be 0 or 1. Refer to section 7.5.
- QR message mode: can be 0 or 1. Refer to section 7.6.
Note that:
- If there are any input encoding parameters that are not in the above values, the program
prints out "Invalid encrypting parameters" and terminates the program.
Examples:
o TranHoang -> 84114971107211197110103
Original string T r a n H o a n g
Encrypted string 84 114 97 110 72 111 97 110 103
Examples:
o TranHoang -> 194326390740263932
Original string T r a n H o a n g
Encrypted string 19 43 26 39 07 40 26 39 32
o NguyenVanA -> 13324650303921263900
Original string N g u y e n V a n A
Encrypted string 13 32 46 50 30 39 21 26 39 00
𝑬(𝒙) = (𝒙 + 𝒅) 𝒎𝒐𝒅 𝒑
In which:
o 𝑬𝒅 (𝒙): The character after being encoded by shifting d positions
o 𝒙: The Character before encoding
o 𝒅: offset
o 𝒑: Number of letters in the alphabet
Regarding the offset d, let s be the number of characters of Account holder name (If
Account holder name has been encoded in the above section, the name must be taken
after the encoding). In this assignment, d is calculated as:
𝒅 = (𝟏𝟏 ∗ 𝒔) 𝒎𝒐𝒅 𝒑
Regarding the alphabet used, the upper- and lower-case alphabets are paired in
consecutive pairs and finally the digits are as follows:
A a B b C c … Z z 0 1 … 9
For example:
o With d = 2: ZzzBaa089Czab -> 011Cbb2AaD1bc
d=2
Original string Z z z B a a 0 8 9 C z a b
Encrypted string 0 1 1 C b b 2 A a D 1 b c
Input 3
100
00020101021BKB0271001142475TranMinhHoang22082021
Output 00020101021BKB0271001142475841149711077105110104721119711010322082021
Example 8
Input 3
200
00020101021BKB0271001142475TranMinhHoang22082021
Output 00020101021BKB02710011424751943263912343933074026393222082021
Explain Encrypt the account holder name according to the specified cipher:
TranMinhHoang -> 19432639123439330740263932
Example 9
Input 3
010
00020101021TrinhThiKhanhDuyen29136412200101HBB
Output 00020101021TrinhThiKhanhDuyen21463192200101HBB
Example 10
Input 3
001
0002010102108162021KHB012100002512112DangVu
Output 444645454654B5A6465MJD456544446956556FcpiXw
Example 11
Input 3
110
00020101021BKB0882003729910DangVanThanh18072020
Output 00020101021BKB019927300288068971101038697110841049711010418072020
Example 12
Input 3
120
00020101021BKB0882003729910DangVanThanh18072020
Example 13
Input 3
011
00020101021NguyenThanhBinh15883012201130HBB
Output pppqpQpQpqQc2KOZDi4VD4v6D4qQpRttSQqpQQRp3vv
Example 14
Input 3
211
00020101021BKB0882003729910DangVanThanh18072020
Output DDDEDdDdDEdJSJDdhhEgeDDEHHDDeEGeheEEdEGehdheeEGeheedHDgEDED
Explain Encrypt the account holder name according to the specified cipher:
DangVanThanh -> 689711010386971108410497110104
Encrypt account number:
0882003729910 -> 0199273002880
QR messsage after performing 2 encrypting steps (account holder name and account
number):
00020101021BKB019927300288003263932212639193326393318072020
Encrypt entire the above QR message with d = 16 (s = 24):
0 -> D, B -> J, 9 -> h, 1 -> d, … (Shift 16 times according to the alphabet in section 7.6)
8. Submission
Students download file NMLT_assigment - English.zip from the e-Learning site. When
extracting this file, you will get the following files:
The qrTool.c file is the initial source code. Students are encouraged to use this source
code for further implementation.
When submitting, students submit their work on the subject's e-Learning site. Students fill
in the code for the assignment like other exercises. Students are provided with 4 places to
submit:
- Part 1 - View QR information (Assignment – View QR information): Students submit
their work and are graded on 30 testcases related to the View QR information section.
- Part 2 - Convert QR format (Assignment – Convert QR format): Students submit
their work and are graded on 30 testcases related to the Convert QR format section.
- Part 3 - Encrypt QR message (Assignment – Encrypt QR message): Students submit
their work and are graded on 20 testcases related to the Ecrypt QR message section.
- Part 4 – Mixed tests (Assignment – Mixed tests): This part includes 20 testcases that
test all 3 parts above, including some difficult testcases. Students need to achieve a
minimum of 7 points in all 3 sections above to be able to submit work to the Mixed
tests. Students who do not submit their work to the Mixed tests will be counted as 0
points for only this part.
In each of the above parts, students have a maximum of 10 attempts. For each attempt,
students have 10 minutes to check and submit the code. Only the first "Check" is scored, the
following times will not be scored. The test results are displayed only after you press the
"Complete" button. The highest score among attempts will be taken as the score for that part.
Assignment score = Part 1 score * 0.3 + Part 2 score * 0.3 + Part 3 score * 0.2 + Part 4 score * 0.2
For example, student A gets 10 points in Part 1, 7 points in Part 2 and 8 points in Part 3.
Student A is eligible to submit Part 4, where A's result is 6 points. Hence:
A’s Assignment score = 10 * 0.3 + 7 * 0.3 + 8 * 0.2 + 6 * 0.2 = 7.9
Students must test their program on MinGW
and Assignment – Test place before submitting.
8.1. Submission deadline
Deadline for submission is 11:55 p.m. Sunday, November 7, 2021. Students submit work
on the e-Learning site of the subject. If a student submits assignment late, the maximum score
for assignment will be 0 points. We DO NOT accept submissions sent via email or any other
form.
8.2. Handling fraud
Assignment must be done BY YOURSELF. Students will be considered fraudulent if:
- There is an unusual similarity between the source code of the submissions. In this case,
ALL submissions are considered fraudulent. Therefore, students must protect the
source code of their assignments.
- Students do not understand the source code written by themselves, except for the parts
of the code provided in the initialization program. Students can consult from any
source, but make sure they understand the meaning of all the lines they write. In case
of not understanding the source code where they refer, students are especially warned
NOT to use this source code; instead use what has been learned to write programs.
- Mistakenly submit another student’s assignment on your personal account.
In the case of cheating, students will get a 0 for the entire subject (not just the assignment).
WE DO NOT ACCEPT ANY INTERPRETATION AND NO EXCEPTION!
After assignment has been submitted, a number of students will be called for random
interviews to prove that the assignment has been done by themselves.
-FIN-
9. Changelog
v1.1:
• Add Changelog
• Add Test place