cipherlink


Namecipherlink JSON
Version 1.0.1 PyPI version JSON
download
home_page
SummaryA Python-based basic ciphering tool library
upload_time2023-09-21 17:55:13
maintainer
docs_urlNone
authorAhmet Erdem
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Cipherlink

A simple library for basic cybersecurity algorithms.

## Project details

This project will be merged with a messaging protocol, 
hence the name. (See https://github.com/ahmeterdem1/SSL-Messager
for details.)

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

_pip install cipherlink_

## Usage

This library is not for real cybersecurity use. Tools
inside here are not complicated and fast enough for that 
use. But this is a simple and fast enough library for 
small projects that requires a tint of security. It creates
a bundle for ciphering, a little all-in-one. It has prime
number generation functions, a hash function, RSA keygen
function and encryption-decryption functions for RSA.

No useful initialization occurs in this class, creating a
cipherlink object just prints the _dir()_ function of the
class.

### hash(str)

Just an analogue of md5. Output is made of all the new internal
state numbers, not just the last one. Pretty much only difference
is that. Return is a string.

### gcd(a, b)

Returns gcd of arguments

### gcdExtended(a, b)

Returns gcd, x, y where x and y are coefficients of the equation:

`ax + by = gcd(a, b)`

This is used to implement a faster key generation in RSA.

### primeByOrder(int)

Takes an integer as the order, then returns the prime in the order.
Useful for generating large primes by just inputting their order.
Default argument is a random 8-bit number plus one, in case 0 is
choosen. If the argument is smaller than 1, raises RangeError.

### primeByRange(int, int)

Returns a list of primes in given range. If the range is invalid, 
raises a RangeError.

### isPrime(int)

Returns true if the argument is a prime. If the argument is smaller
than 2, returns false.

### keygenRsa(p, q, smallest)

Creates a tuple of public and private key and returns it. Public key
is itself a tuple. p and q as primes can be given. _smallest_ determines 
the e. If true, which is the default, e is the smallest number possible. 
If false, e is chosen randomly within the list. If randomly choosen, 
private key generation takes a lot of time, therefore the default is true.

If given p and q are not primes, raises an ArgError.

### encryptorRsa(public, message)

Takes in the public key and the message, then encrypts the message. Returns
the encrypted message as a tuple. Every element in this tuple represents a
character.

### decryptorRsa(public, private, message)

Takes in the keys and the encrypted message, then returns the decrypted message.
Return type is string this time.

### encryptorRsa2(public, message)

Same as the original one. Only difference is that, this works by grouping
characters by 2, appending their ascii values, using the resultant integer.
With this method, this function is not an overcomplicated caesar cipher 
anymore.

### decryptorRsa2(public, private, message)

Decrypts RSA messages grouped in 2.

## Known issues

### Random Exceptions and Errors

Both decryptor functions rarely raise exceptions or result in an incorrect
message. One of the reasons for that was, generated private key could be 1
sometimes. This makes the for loop exit immediately. So no decryption occurs.
This is solved now. The only remaining reason known for this issue is the
information loss during multiplications of large numbers. Frequency of this
issue happening is measured to be around %4 with pypy3 as compiler.

Beware that every time this issue happens, indeed no decryption occurs.
You can see this with debugging, for some reason the encrypted message
is passed as the result in the decryptor despite the private key being
larger than 2. This may be due to some mathematical problem in our method
of private key calculation. But %4 is small enough to be practical.

### Algorithm is annoyingly slow

Algorithm is not the only thing that is slow here. CPython is the real slow
thing in here. Our recommendation is to use pypy as the compiler. Pypy is 
measured to be around 10 to 20 times faster than CPython during keygen,
encryption and decryption combined. This is probably due to the optimizations
on loops in pypy. CPython takes its time during the for and while loops of
said operations. We have to sacrifice the speed here with that loops because
otherwise we would have to do operations on really large numbers. That will
result in the above said errors. Just using C/C++ is still an option.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cipherlink",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Ahmet Erdem",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/36/69/7da806610ab3f41bd8b52d0e70c67bf8500e9b6d9811298c57af0d915c0d/cipherlink-1.0.1.tar.gz",
    "platform": null,
    "description": "# Cipherlink\n\nA simple library for basic cybersecurity algorithms.\n\n## Project details\n\nThis project will be merged with a messaging protocol, \nhence the name. (See https://github.com/ahmeterdem1/SSL-Messager\nfor details.)\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n_pip install cipherlink_\n\n## Usage\n\nThis library is not for real cybersecurity use. Tools\ninside here are not complicated and fast enough for that \nuse. But this is a simple and fast enough library for \nsmall projects that requires a tint of security. It creates\na bundle for ciphering, a little all-in-one. It has prime\nnumber generation functions, a hash function, RSA keygen\nfunction and encryption-decryption functions for RSA.\n\nNo useful initialization occurs in this class, creating a\ncipherlink object just prints the _dir()_ function of the\nclass.\n\n### hash(str)\n\nJust an analogue of md5. Output is made of all the new internal\nstate numbers, not just the last one. Pretty much only difference\nis that. Return is a string.\n\n### gcd(a, b)\n\nReturns gcd of arguments\n\n### gcdExtended(a, b)\n\nReturns gcd, x, y where x and y are coefficients of the equation:\n\n`ax + by = gcd(a, b)`\n\nThis is used to implement a faster key generation in RSA.\n\n### primeByOrder(int)\n\nTakes an integer as the order, then returns the prime in the order.\nUseful for generating large primes by just inputting their order.\nDefault argument is a random 8-bit number plus one, in case 0 is\nchoosen. If the argument is smaller than 1, raises RangeError.\n\n### primeByRange(int, int)\n\nReturns a list of primes in given range. If the range is invalid, \nraises a RangeError.\n\n### isPrime(int)\n\nReturns true if the argument is a prime. If the argument is smaller\nthan 2, returns false.\n\n### keygenRsa(p, q, smallest)\n\nCreates a tuple of public and private key and returns it. Public key\nis itself a tuple. p and q as primes can be given. _smallest_ determines \nthe e. If true, which is the default, e is the smallest number possible. \nIf false, e is chosen randomly within the list. If randomly choosen, \nprivate key generation takes a lot of time, therefore the default is true.\n\nIf given p and q are not primes, raises an ArgError.\n\n### encryptorRsa(public, message)\n\nTakes in the public key and the message, then encrypts the message. Returns\nthe encrypted message as a tuple. Every element in this tuple represents a\ncharacter.\n\n### decryptorRsa(public, private, message)\n\nTakes in the keys and the encrypted message, then returns the decrypted message.\nReturn type is string this time.\n\n### encryptorRsa2(public, message)\n\nSame as the original one. Only difference is that, this works by grouping\ncharacters by 2, appending their ascii values, using the resultant integer.\nWith this method, this function is not an overcomplicated caesar cipher \nanymore.\n\n### decryptorRsa2(public, private, message)\n\nDecrypts RSA messages grouped in 2.\n\n## Known issues\n\n### Random Exceptions and Errors\n\nBoth decryptor functions rarely raise exceptions or result in an incorrect\nmessage. One of the reasons for that was, generated private key could be 1\nsometimes. This makes the for loop exit immediately. So no decryption occurs.\nThis is solved now. The only remaining reason known for this issue is the\ninformation loss during multiplications of large numbers. Frequency of this\nissue happening is measured to be around %4 with pypy3 as compiler.\n\nBeware that every time this issue happens, indeed no decryption occurs.\nYou can see this with debugging, for some reason the encrypted message\nis passed as the result in the decryptor despite the private key being\nlarger than 2. This may be due to some mathematical problem in our method\nof private key calculation. But %4 is small enough to be practical.\n\n### Algorithm is annoyingly slow\n\nAlgorithm is not the only thing that is slow here. CPython is the real slow\nthing in here. Our recommendation is to use pypy as the compiler. Pypy is \nmeasured to be around 10 to 20 times faster than CPython during keygen,\nencryption and decryption combined. This is probably due to the optimizations\non loops in pypy. CPython takes its time during the for and while loops of\nsaid operations. We have to sacrifice the speed here with that loops because\notherwise we would have to do operations on really large numbers. That will\nresult in the above said errors. Just using C/C++ is still an option.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python-based basic ciphering tool library",
    "version": "1.0.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c3cdd24d578ccf61cbe6dfb97051378c502fe0bfd6cd5b7c57646e9e9a414065",
                "md5": "bcba6c54b018a1324a5909f41f569190",
                "sha256": "e7767163a05fe42e0987b4066b2f1c6b71e0d2f06667fd125f86ec0649c425b7"
            },
            "downloads": -1,
            "filename": "cipherlink-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bcba6c54b018a1324a5909f41f569190",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8206,
            "upload_time": "2023-09-21T17:55:11",
            "upload_time_iso_8601": "2023-09-21T17:55:11.258336Z",
            "url": "https://files.pythonhosted.org/packages/c3/cd/d24d578ccf61cbe6dfb97051378c502fe0bfd6cd5b7c57646e9e9a414065/cipherlink-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "36697da806610ab3f41bd8b52d0e70c67bf8500e9b6d9811298c57af0d915c0d",
                "md5": "8e829615d294221affcda9d936f7ddfd",
                "sha256": "1db917868c149382d6e7d454a274ecb64229814dc6b577540abca3954ac62503"
            },
            "downloads": -1,
            "filename": "cipherlink-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8e829615d294221affcda9d936f7ddfd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6162,
            "upload_time": "2023-09-21T17:55:13",
            "upload_time_iso_8601": "2023-09-21T17:55:13.408956Z",
            "url": "https://files.pythonhosted.org/packages/36/69/7da806610ab3f41bd8b52d0e70c67bf8500e9b6d9811298c57af0d915c0d/cipherlink-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-21 17:55:13",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cipherlink"
}
        
Elapsed time: 0.11180s