Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
P
parallel_encryption
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tammam.alsoleman
parallel_encryption
Commits
c916f92d
Commit
c916f92d
authored
Nov 28, 2025
by
tammam.alsoleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement EncryptionProcessor class
parent
21de2cd4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
1 deletion
+44
-1
EncryptionProcessor.java
src/main/java/consumer/EncryptionProcessor.java
+44
-1
No files found.
src/main/java/consumer/EncryptionProcessor.java
View file @
c916f92d
package
consumer
;
package
consumer
;
public
class
EncryptionProcessor
{
public
class
EncryptionProcessor
{
}
private
final
int
shiftKey
;
public
EncryptionProcessor
(
int
shiftKey
)
{
this
.
shiftKey
=
shiftKey
;
}
public
String
processLine
(
String
line
)
{
// Handle empty or null lines
if
(
line
==
null
||
line
.
trim
().
isEmpty
())
{
return
line
;
}
return
caesarCipher
(
line
,
shiftKey
);
}
private
String
caesarCipher
(
String
text
,
int
shift
)
{
StringBuilder
result
=
new
StringBuilder
();
for
(
char
character
:
text
.
toCharArray
())
{
if
(
Character
.
isLetter
(
character
))
{
// Determine if uppercase or lowercase
char
base
=
Character
.
isLowerCase
(
character
)
?
'a'
:
'A'
;
// Calculate new position with wrap-around
int
originalPosition
=
character
-
base
;
int
newPosition
=
(
originalPosition
+
shift
)
%
26
;
// Handle negative shifts
if
(
newPosition
<
0
)
{
newPosition
+=
26
;
}
char
encryptedChar
=
(
char
)
(
base
+
newPosition
);
result
.
append
(
encryptedChar
);
}
else
{
// Keep non-letter characters unchanged
result
.
append
(
character
);
}
}
return
result
.
toString
();
}
public
int
getShiftKey
()
{
return
shiftKey
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment