Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
S
Synchronization_of_threads
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
yazan.halloul
Synchronization_of_threads
Commits
a5c00a27
Commit
a5c00a27
authored
Nov 28, 2023
by
yazan.halloul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build important classes for implement system
parent
bf197cb7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
0 deletions
+71
-0
DESAlgorithm.java
src/main/java/benefit_classes/DESAlgorithm.java
+33
-0
LineSequence.java
src/main/java/benefit_classes/LineSequence.java
+24
-0
LineSequenceComparator.java
src/main/java/benefit_classes/LineSequenceComparator.java
+14
-0
No files found.
src/main/java/benefit_classes/DESAlgorithm.java
0 → 100644
View file @
a5c00a27
package
benefit_classes
;
import
javax.crypto.*
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.UnsupportedEncodingException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Base64
;
public
class
DESAlgorithm
{
private
SecretKey
secretKey
;
public
DESAlgorithm
(
String
encodedKey
)
{
// The common encodedKey is: fzI0SlHWAfc=
// decode the base64 encoded string
byte
[]
decodedKey
=
Base64
.
getDecoder
().
decode
(
encodedKey
);
// rebuild key using SecretKeySpec
secretKey
=
new
SecretKeySpec
(
decodedKey
,
0
,
decodedKey
.
length
,
"DES"
);
}
public
String
encryption
(
String
text
)
throws
NoSuchPaddingException
,
NoSuchAlgorithmException
,
UnsupportedEncodingException
,
IllegalBlockSizeException
,
BadPaddingException
,
InvalidKeyException
{
Cipher
desCipher
=
Cipher
.
getInstance
(
"DES"
);
desCipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
secretKey
);
byte
[]
textEncrypted
=
desCipher
.
doFinal
(
text
.
getBytes
(
"UTF-8"
));
return
Base64
.
getEncoder
().
encodeToString
(
textEncrypted
);
}
public
String
decryption
(
String
text
)
throws
NoSuchPaddingException
,
NoSuchAlgorithmException
,
InvalidKeyException
,
UnsupportedEncodingException
,
IllegalBlockSizeException
,
BadPaddingException
{
Cipher
desCipher
=
Cipher
.
getInstance
(
"DES"
);
desCipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKey
);
byte
[]
textDecrypted
=
desCipher
.
doFinal
(
Base64
.
getDecoder
().
decode
(
text
));
return
new
String
(
textDecrypted
,
"UTF-8"
);
}
}
src/main/java/benefit_classes/LineSequence.java
0 → 100644
View file @
a5c00a27
package
benefit_classes
;
public
class
LineSequence
{
private
String
line
;
private
int
sequence
;
public
LineSequence
(
String
line
,
int
sequence
)
{
this
.
line
=
line
;
this
.
sequence
=
sequence
;
}
public
void
setLine
(
String
line
)
{
this
.
line
=
line
;
}
public
String
getLine
()
{
return
line
;
}
public
int
getSequence
()
{
return
sequence
;
}
}
src/main/java/benefit_classes/LineSequenceComparator.java
0 → 100644
View file @
a5c00a27
package
benefit_classes
;
import
java.util.Comparator
;
public
class
LineSequenceComparator
implements
Comparator
<
LineSequence
>
{
@Override
public
int
compare
(
LineSequence
s1
,
LineSequence
s2
)
{
if
(
s1
.
getSequence
()
>
s2
.
getSequence
())
return
1
;
else
if
(
s1
.
getSequence
()
<
s2
.
getSequence
())
return
-
1
;
return
0
;
}
}
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