An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

Public-Key-Ciphers



Stars
Total Downloads
Latest Stable Version
License

## 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)