https://github.com/n1ghtf1re/public-key-ciphers
The implementation of the public key ciphers: Elgamal
https://github.com/n1ghtf1re/public-key-ciphers
cryptography elgamal elgamal-encryption public-key-cryptography public-key-encrption
Last synced: about 2 months ago
JSON representation
The implementation of the public key ciphers: Elgamal
- Host: GitHub
- URL: https://github.com/n1ghtf1re/public-key-ciphers
- Owner: N1ghtF1re
- License: mit
- Created: 2018-10-07T18:39:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-11T10:01:57.000Z (almost 7 years ago)
- Last Synced: 2025-02-28T07:54:58.647Z (8 months ago)
- Topics: cryptography, elgamal, elgamal-encryption, public-key-cryptography, public-key-encrption
- Language: Java
- Homepage:
- Size: 41 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Public-Key-Ciphers
## About the library
The library contains one public key ciphers: Elgamal## Class Elgamal:
### Constructors:
- **Elgamal(long p, long x, long k)** . p - prime number, x - Private key, number of range (1; p - 1), Session key, mutually prime with p number of range (1; p - 1)### Methods:
- **encrypt(byte[] plaintext)** - Encodes an array of bytes
- One byte of source array turns into two elements of the array of ints.
- CIPHERTEXT[i] = g^k mod p
- CIPHERTEXT[i+1] = (y^k * PlAINTEXT[i/2]) mod p
- **decrypt(byte[])** - Decodes an array of ints
- Two elements of ciphertext array (int[]) turns into one byte of plaintext array
- (b = ciphertext[i + 1], a = ciphertext[i])
- PLAINTEXT[i/2] = ( b * (a^x)^-1 ) mod p = (b * (a^x)^(phi(p) - 1)) mod p, phi - Euler function
- **getPublicKey()** - return Public Key object (p, g, y)