c-exam-kit 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/run.js ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const prompt = require('prompt-sync')({sigint: true});
5
+
6
+ const codesDir = 'C:\\codes';
7
+ const outputDir = 'C:\\c-exam-files';
8
+
9
+ // Auto-initialize if needed
10
+ if (!fs.existsSync(codesDir)) {
11
+ console.log('\n⚙ Initializing C Exam Kit...');
12
+ try {
13
+ require(path.join(__dirname, '..', 'make-codes.js'));
14
+ } catch (err) {
15
+ console.error('✗ Initialization failed:', err.message);
16
+ process.exit(1);
17
+ }
18
+ }
19
+
20
+ console.log('\n╔════════════════════════════════════╗');
21
+ console.log('║ C PROGRAMMING EXAM KIT v1.0.0 ║');
22
+ console.log('║ Secure Code Repository ║');
23
+ console.log('╚════════════════════════════════════╝\n');
24
+
25
+ // Get password with hidden input
26
+ const pass = prompt.hide('Enter Access Key: ');
27
+
28
+ if (pass !== 'exam_15') {
29
+ console.log('\n✗ Invalid key. Access denied.\n');
30
+ process.exit(1);
31
+ }
32
+
33
+ console.log('✓ Access granted!\n');
34
+
35
+ const files = fs.readdirSync(codesDir).filter(f => f.endsWith('.c')).sort();
36
+
37
+ console.log('Available C Programs:');
38
+ console.log('─────────────────────');
39
+ files.forEach((f, i) => {
40
+ const num = String(i + 1).padStart(2, '0');
41
+ console.log(` ${num}. ${f}`);
42
+ });
43
+ console.log('');
44
+
45
+ const ans = prompt('Select program (enter number): ');
46
+ const idx = parseInt(ans) - 1;
47
+
48
+ if (isNaN(idx) || idx < 0 || idx >= files.length) {
49
+ console.log('\n✗ Invalid selection!\n');
50
+ process.exit(1);
51
+ }
52
+
53
+ const selected = files[idx];
54
+ const src = path.join(codesDir, selected);
55
+ const dest = path.join(outputDir, selected);
56
+
57
+ try {
58
+ // Create output directory
59
+ fs.mkdirSync(outputDir, {recursive:true});
60
+
61
+ // Copy file
62
+ fs.copyFileSync(src, dest);
63
+
64
+ console.log('\n╔════════════════════════════════════╗');
65
+ console.log('║ ✓ FILE EXTRACTED SUCCESS ║');
66
+ console.log('╚════════════════════════════════════╝');
67
+ console.log(`\nProgram: ${selected}`);
68
+ console.log(`Location: ${dest}\n`);
69
+ console.log('File is ready for editing in your C IDE.\n');
70
+ process.exit(0);
71
+ } catch (err) {
72
+ console.log(`\n✗ Error: ${err.message}\n`);
73
+ process.exit(1);
74
+ }
@@ -0,0 +1,44 @@
1
+ #include<stdio.h>
2
+ #include<conio.h>
3
+ #include<string.h>
4
+
5
+ char encrypt(char,int);
6
+ char decrypt(char,int);
7
+
8
+ void main(){
9
+ char plain[20];
10
+ char cipher[20];
11
+ int key;
12
+ int i;
13
+ clrscr();
14
+
15
+ printf("Enter Plain Text :");
16
+ scanf("%s",&plain);
17
+ printf("Enter Key :");
18
+ scanf("%d",&key);
19
+
20
+ for(i=0;i<strlen(plain);i++){
21
+ cipher[i]=encrypt(plain[i],key);
22
+ }
23
+ cipher[i]='\0';
24
+ printf("Cipher Text =%s\n",cipher);
25
+
26
+ for(i=0;i<strlen(cipher);i++){
27
+ plain[i]=decrypt(cipher[i],key);
28
+ }
29
+ plain[i]='\0';
30
+ printf("Plain Text =%s",plain);
31
+ getch();
32
+ }
33
+
34
+ char encrypt(char p, int k){
35
+ int c;
36
+ c=(p-'A'+k)%26+'A' ;
37
+ return c;
38
+ }
39
+
40
+ char decrypt(char c,int k){
41
+ int p;
42
+ p=(c-'A'-k)%26+'A';
43
+ return p;
44
+ }
@@ -0,0 +1,62 @@
1
+ #include<stdio.h>
2
+ #include<conio.h>
3
+ #include<ctype.h>
4
+ #include<string.h>
5
+
6
+ void main(){
7
+ char plain[20] = "HELLOWORLD";
8
+ int key = 4;
9
+ char c_matrix[20][20];
10
+ char c_text[20];
11
+ int i,j,row,col,x,y,r=0,down=0;
12
+
13
+ clrscr();
14
+
15
+ col = strlen(plain);
16
+ row = key;
17
+
18
+ for(x=0; x<row; x++){
19
+ for(y=0; y<col; y++){
20
+ c_matrix[x][y] = '*';
21
+ }
22
+ }
23
+
24
+ // Fill plain text at zig zag locations
25
+ for(j=0; j<col; j++){
26
+ c_matrix[r][j] = plain[j];
27
+
28
+ if(r == 0){
29
+ down = 1;
30
+ }
31
+ else if(r == key - 1){
32
+ down = 0;
33
+ }
34
+
35
+ if(down == 1){
36
+ r = r + 1;
37
+ }
38
+ else{
39
+ r = r - 1;
40
+ }
41
+ }
42
+
43
+ // MATRIX DISPLAY
44
+ for(x=0; x<row; x++){
45
+ for(y=0; y<col; y++){
46
+ printf("%c",c_matrix[x][y]);
47
+ }
48
+ printf("\n");
49
+ }
50
+
51
+ // CIPHER TEXT DISPLAY
52
+ printf("\nCIPHER TEXT = ");
53
+ for(x=0; x<row; x++){
54
+ for(y=0; y<col; y++){
55
+ if(c_matrix[x][y] != '*'){
56
+ printf("%c",c_matrix[x][y]);
57
+ }
58
+ }
59
+ }
60
+
61
+ getch();
62
+ }
@@ -0,0 +1,63 @@
1
+ #include<stdio.h>
2
+ #include<string.h>
3
+ #include<conio.h>
4
+ #include<ctype.h>
5
+
6
+ void main(){
7
+ char plain_text[]="WELCOMETOTEST", key[10]="461253", c_text[20];
8
+ char c_matrix[20][20];
9
+ int i,j,col,row,c=0,k=0;
10
+
11
+ clrscr();
12
+
13
+ col = strlen(key);
14
+ row = (strlen(plain_text) + (strlen(key) - 1)) / strlen(key);
15
+
16
+ // Arrange Plaintext in c_matrix
17
+ for(i=0; i<row; i++)
18
+ {
19
+ for(j=0; j<col; j++)
20
+ {
21
+ if(c < strlen(plain_text))
22
+ {
23
+ c_matrix[i][j] = plain_text[c];
24
+ c = c + 1;
25
+ }
26
+ else
27
+ {
28
+ c_matrix[i][j] = 'x';
29
+ }
30
+ }
31
+ }
32
+
33
+ // Display c_matrix
34
+ c = 0;
35
+ for(i=0; i<row; i++)
36
+ {
37
+ for(j=0; j<col; j++)
38
+ {
39
+ printf("%c", c_matrix[i][j]);
40
+ }
41
+ printf("\n");
42
+ }
43
+
44
+ for(k=1; k<=col; k++)
45
+ {
46
+ for(j=0; j<col; j++)
47
+ {
48
+ if(key[j]-'0' == k)
49
+ {
50
+ for(i=0; i<row; i++)
51
+ {
52
+ c_text[c] = c_matrix[i][j];
53
+ c = c + 1;
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ c_text[c] = '\0';
60
+ printf("\nCIPHER TEXT IS = %s", c_text);
61
+
62
+ getch();
63
+ }
@@ -0,0 +1,25 @@
1
+ #include<stdio.h>
2
+ #include<conio.h>
3
+ #include<ctype.h>
4
+ void main() {
5
+ char pswd[20];
6
+ int i,len=0,alpha=0,digit=0,sp=0;
7
+ printf("ENTER A PASSWORD: ");
8
+ scanf("%s",&pswd);
9
+ //pswd length Test
10
+ if(strlen(pswd)>8) {
11
+ len = 1; }
12
+ //alphabates Test
13
+ for(i=0;i<strlen(pswd);i++) {
14
+ if(isalpha(pswd[i])) {
15
+ alpha = 1; }
16
+ if(isdigit(pswd[i])) {
17
+ digit = 1; }
18
+ if(pswd[i]=='@' || pswd[i]=='#' || pswd[i]=='%' || pswd[i]=='&') {
19
+ sp = 1; } }
20
+ if(alpha && digit && sp) {
21
+ printf("PASSWORDIS STRONG - ACCEPTED"); }
22
+ else {
23
+ printf("PASSWORD IS WEAK - NOT ACCEPTED"); }
24
+ getch();
25
+ }
@@ -0,0 +1,35 @@
1
+ #include<stdio.h>
2
+ #include<conio.h>
3
+ #include<string.h>
4
+ #include<ctype.h>
5
+ void main(){
6
+ int i;
7
+ char plntxt[30],ciphertxt[30],key[30];
8
+ clrscr();
9
+ printf("Enter your plain text: ");
10
+ scanf("%s",&plntxt);
11
+ printf("Enter your key (same length as plain text): ");
12
+ scanf("%s",&key);
13
+ for(i=0; i<strlen(plntxt); i++){
14
+ if(isupper(plntxt[i])){
15
+ ciphertxt[i] = (((plntxt[i]-'A') ^ (key[i]-'A'))% 26)+'A';
16
+ }
17
+ if(islower(plntxt[i])){
18
+ ciphertxt[i] = (((plntxt[i]-'a') ^ (key[i]-'a'))% 26 )+ 'a';
19
+ }
20
+ }
21
+ ciphertxt[i] = '\0';
22
+ printf("Encrypted text: %s\n",ciphertxt);
23
+
24
+ for(i=0; i<strlen(ciphertxt); i++){
25
+ if(isupper(ciphertxt[i])){
26
+ plntxt[i] = (((ciphertxt[i]-'A') ^ (key[i]-'A'))% 26)+'A';
27
+ }
28
+ if(islower(ciphertxt[i])){
29
+ plntxt[i] = (((ciphertxt[i]-'a') ^ (key[i]-'a'))% 26 )+ 'a';
30
+ }
31
+ }
32
+ plntxt[i] = '\0';
33
+ printf("Decrypted text: %s\n",plntxt);
34
+ getch();
35
+ }
package/index.js ADDED
@@ -0,0 +1,45 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
5
+ <title>Pastebin.com - Access Denied Warning</title>
6
+ <!-- Global site tag (gtag.js) - Google Analytics -->
7
+
8
+ </head>
9
+ <body style="text-align: center;margin:10px 0 0 0;background-color:#E0E0E0;font-family:segoe ui,trebuchet MS,Lucida Sans Unicode,Lucida Sans,Sans-Serif">
10
+ <div style="margin: auto;background:#fff;width:485px;padding:25px;display:inline-block;border-radius:10px">
11
+ <div style="clear: both">
12
+
13
+ <div style="width:80px;height:80px;margin: 0 auto">
14
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg"
15
+ xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
16
+ viewBox="0 0 497.472 497.472" style="enable-background:new 0 0 497.472 497.472;"
17
+ xml:space="preserve">
18
+
19
+ <g transform="matrix(1.25 0 0 -1.25 0 45)">
20
+ <g>
21
+ <g>
22
+ <path style="fill:#FFCC4D;" d="M24.374-357.857c-20.958,0-30.197,15.223-20.548,33.826L181.421,17.928
23
+ c9.648,18.603,25.463,18.603,35.123,0L394.14-324.031c9.671-18.603,0.421-33.826-20.548-33.826H24.374z"/>
24
+ <path style="fill:#231F20;" d="M173.605-80.922c0,14.814,10.934,23.984,25.395,23.984c14.12,0,25.407-9.512,25.407-23.984
25
+ V-216.75c0-14.461-11.287-23.984-25.407-23.984c-14.461,0-25.395,9.182-25.395,23.984V-80.922z M171.489-289.056
26
+ c0,15.167,12.345,27.511,27.511,27.511c15.167,0,27.523-12.345,27.523-27.511c0-15.178-12.356-27.523-27.523-27.523
27
+ C183.834-316.579,171.489-304.234,171.489-289.056"/>
28
+ </g>
29
+ </g>
30
+ </g>
31
+
32
+ </svg>
33
+ </div>
34
+
35
+ <h2 style="color:#181818;font-size:140%">Pastebin.com has blocked your IP</h2>
36
+ <h3 style="color:#181818;font-size:100%;font-weight:normal">We have <i>temporarily</i> blocked your IP from accessing our website because we have <i><b>detected unnatural browsing behavior</b></i>.</h3>
37
+
38
+ <div style="border:3px dotted #C03;background:#f9f9f9;padding:5px 10px;border-radius:5px">
39
+ <h3 style="color:#181818;font-size: 100%;font-weight:normal">If you are trying to <b>scrape</b> our website, your IP will be blocked, we recommend that you contact <a href="/cdn-cgi/l/email-protection#dfacbeb3baac9fafbeacabbabdb6b1f1bcb0b2" style="color:#C03"><span class="__cf_email__" data-cfemail="6615070a0315261607151203040f084805090b">[email&#160;protected]</span></a> for a possible solution.</h3>
40
+ <div style="text-align:right">Thanks, The Pastebin Team</div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ <script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script></body>
45
+ </html>
package/make-codes.js ADDED
@@ -0,0 +1,48 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const codesPath = 'C:\\codes';
5
+
6
+ console.log('\n=== C Exam Kit Setup ===');
7
+ console.log('Creating code repository...');
8
+
9
+ try {
10
+ fs.mkdirSync(codesPath, {recursive:true});
11
+ console.log('✓ Directory created at: C:\\codes\\');
12
+ } catch (err) {
13
+ console.error('✗ Error creating directory:', err.message);
14
+ process.exit(1);
15
+ }
16
+
17
+ const codes = {
18
+ '01_hello_world.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n clrscr();\n printf("Hello, World!");\n getch();\n}',
19
+ '02_addition.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int a,b,sum;\n clrscr();\n printf("Enter two numbers: ");\n scanf("%d %d",&a,&b);\n sum=a+b;\n printf("Sum = %d",sum);\n getch();\n}',
20
+ '03_even_odd.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int n;\n clrscr();\n printf("Enter a number: ");\n scanf("%d",&n);\n if(n%2==0)\n printf("%d is Even",n);\n else\n printf("%d is Odd",n);\n getch();\n}',
21
+ '04_largest_three.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int a,b,c;\n clrscr();\n printf("Enter three numbers: ");\n scanf("%d %d %d",&a,&b,&c);\n if(a>b&&a>c)\n printf("Largest = %d",a);\n else if(b>c)\n printf("Largest = %d",b);\n else\n printf("Largest = %d",c);\n getch();\n}',
22
+ '05_factorial.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int n,i;\n long fact=1;\n clrscr();\n printf("Enter a number: ");\n scanf("%d",&n);\n for(i=1;i<=n;i++)\n fact=fact*i;\n printf("Factorial = %ld",fact);\n getch();\n}',
23
+ '06_fibonacci.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int n,i,a=0,b=1,c;\n clrscr();\n printf("Enter number of terms: ");\n scanf("%d",&n);\n printf("%d %d ",a,b);\n for(i=2;i<n;i++)\n {\n c=a+b;\n printf("%d ",c);\n a=b;\n b=c;\n }\n getch();\n}',
24
+ '07_prime.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int n,i,flag=0;\n clrscr();\n printf("Enter a number: ");\n scanf("%d",&n);\n for(i=2;i<=n/2;i++)\n {\n if(n%i==0)\n {flag=1;break;}\n }\n if(flag==0)\n printf("%d is Prime",n);\n else\n printf("%d is Not Prime",n);\n getch();\n}',
25
+ '08_swap.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int a,b,temp;\n clrscr();\n printf("Enter two numbers: ");\n scanf("%d %d",&a,&b);\n temp=a;\n a=b;\n b=temp;\n printf("After swap: a=%d, b=%d",a,b);\n getch();\n}',
26
+ '09_reverse_number.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int n,rev=0,rem;\n clrscr();\n printf("Enter a number: ");\n scanf("%d",&n);\n while(n!=0)\n {\n rem=n%10;\n rev=rev*10+rem;\n n=n/10;\n }\n printf("Reversed = %d",rev);\n getch();\n}',
27
+ '10_armstrong.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int n,temp,rem,sum=0;\n clrscr();\n printf("Enter a number: ");\n scanf("%d",&n);\n temp=n;\n while(temp!=0)\n {\n rem=temp%10;\n sum=sum+rem*rem*rem;\n temp=temp/10;\n }\n if(sum==n)\n printf("%d is Armstrong",n);\n else\n printf("%d is Not Armstrong",n);\n getch();\n}',
28
+ '11_bubble_sort.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int a[50],i,j,n,temp;\n clrscr();\n printf("Enter size: ");\n scanf("%d",&n);\n printf("Enter elements: ");\n for(i=0;i<n;i++)\n scanf("%d",&a[i]);\n for(i=0;i<n-1;i++)\n for(j=0;j<n-i-1;j++)\n if(a[j]>a[j+1])\n {\n temp=a[j];\n a[j]=a[j+1];\n a[j+1]=temp;\n }\n printf("Sorted: ");\n for(i=0;i<n;i++)\n printf("%d ",a[i]);\n getch();\n}',
29
+ '12_linear_search.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int a[50],i,n,key,found=0;\n clrscr();\n printf("Enter size: ");\n scanf("%d",&n);\n printf("Enter elements: ");\n for(i=0;i<n;i++)\n scanf("%d",&a[i]);\n printf("Enter search key: ");\n scanf("%d",&key);\n for(i=0;i<n;i++)\n if(a[i]==key)\n {\n printf("Found at index %d",i);\n found=1;\n break;\n }\n if(!found)printf("Not found");\n getch();\n}',
30
+ '13_string_length.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n char s[100];\n int len=0;\n clrscr();\n printf("Enter string: ");\n gets(s);\n while(s[len]!=\'\\0\')\n len++;\n printf("Length = %d",len);\n getch();\n}',
31
+ '14_palindrome.c': '#include<stdio.h>\n#include<conio.h>\n#include<string.h>\nvoid main()\n{\n char s[100],rev[100];\n clrscr();\n printf("Enter string: ");\n gets(s);\n strcpy(rev,s);\n strrev(rev);\n if(strcmp(s,rev)==0)\n printf("Palindrome");\n else\n printf("Not Palindrome");\n getch();\n}',
32
+ '15_star_pattern.c': '#include<stdio.h>\n#include<conio.h>\nvoid main()\n{\n int i,j,n;\n clrscr();\n printf("Enter rows: ");\n scanf("%d",&n);\n for(i=1;i<=n;i++)\n {\n for(j=1;j<=i;j++)\n printf("* ");\n printf("\\n");\n }\n getch();\n}',
33
+ '16_factorial_recursion.c': '#include<stdio.h>\n#include<conio.h>\nlong factorial(int n)\n{\n if(n==0||n==1)return 1;\n return n*factorial(n-1);\n}\nvoid main()\n{\n int n;\n clrscr();\n printf("Enter a number: ");\n scanf("%d",&n);\n printf("Factorial = %ld",factorial(n));\n getch();\n}'
34
+ };
35
+
36
+ let successCount = 0;
37
+
38
+ Object.entries(codes).forEach(([f,c]) => {
39
+ try {
40
+ fs.writeFileSync(path.join(codesPath, f), c);
41
+ successCount++;
42
+ } catch (err) {
43
+ console.error(`✗ Failed to create ${f}:`, err.message);
44
+ }
45
+ });
46
+
47
+ console.log(`✓ Successfully created ${successCount} C files in C:\\codes\\`);
48
+ console.log('\n✓ Setup complete! Run the app with: c-exam-kit\n');
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "c-exam-kit",
3
+ "version": "1.0.9",
4
+ "description": "C Programming Exam Kit - Secure Code Repository",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "c-exam-kit": "./bin/run.js"
8
+ },
9
+ "dependencies": {
10
+ "prompt-sync": "^4.2.0"
11
+ },
12
+ "scripts": {
13
+ "setup": "node make-codes.js"
14
+ },
15
+ "keywords": ["c", "exam", "code", "repository"],
16
+ "author": "",
17
+ "license": "MIT"
18
+ }