Skip to content

Cryptographic Algorithms in PyDataStructs #592

Open
@czgdp1807

Description

@czgdp1807

Let's create a fake example (assume that cryptographic algorithms are already there in pydatastructs)

from pydatastructs import crypto

text = "Hello world!"
encrypted_text = crypto.sha256(text, encrypt=True)
decrypted_text = crypto.sha256(text, decrypt=True)
assert(text == decrytpted_text)
print("Encrypted text: ", encrypted_text)

Another example,

from pydatastructs import crypto

text = "Hi there!"
encrypted_text = crypto.sha256(text, key=key, encrypt=True)

Another case is we can have two functions, sha256_encrypt or sha256_decrypt. sha256 with encrypt and decrypt is a bit risky because if by chance we pass incorrect value to encrypt or decrypt then it can mess things up.

sha256_encrypt and sha256_decrypt.

For ChaCha20,

def chacha20(key, nonce, counter):
   ...

or,

def chacha20(key):
    ...
    # nonce and counter will be generated here
  1. Fixing bugs - that is easy, doesn't involve
  2. Adding a new feature - a cryptographic algorithm, a sorting algorithm - figure out how the function signature would look like. sort(list), sort(array), sort(set), sort(iterator), sort(list, reverse=True),
def sort(obj, reverse=False):
    ...

@Susmita331

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions