{"id":30503573,"url":"https://github.com/nsk89/netcrypt","last_synced_at":"2025-08-25T13:27:50.171Z","repository":{"id":57445626,"uuid":"155030391","full_name":"nsk89/netcrypt","owner":"nsk89","description":"simplifying socket data stream cryptography using RSA public keys and AES data encryption, using PyCryptodome cryptographic primitives","archived":false,"fork":false,"pushed_at":"2018-10-31T21:05:41.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-29T17:21:03.089Z","etag":null,"topics":["aes-encryption","cryptography","network-secuirty","pycryptodome","python","python3","rsa-encryption","socket-communication"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/netcrypt/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nsk89.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-28T03:06:56.000Z","updated_at":"2025-05-04T20:10:34.000Z","dependencies_parsed_at":"2022-09-26T17:30:57.160Z","dependency_job_id":null,"html_url":"https://github.com/nsk89/netcrypt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nsk89/netcrypt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsk89%2Fnetcrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsk89%2Fnetcrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsk89%2Fnetcrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsk89%2Fnetcrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nsk89","download_url":"https://codeload.github.com/nsk89/netcrypt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsk89%2Fnetcrypt/sbom","scorecard":{"id":697262,"data":{"date":"2025-08-11","repo":{"name":"github.com/nsk89/netcrypt","commit":"de9655056d7e0c7c5741609ebd3a35ef5d1f24c2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/15 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 2-Clause \"Simplified\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-22T04:04:36.833Z","repository_id":57445626,"created_at":"2025-08-22T04:04:36.833Z","updated_at":"2025-08-22T04:04:36.833Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272074705,"owners_count":24868902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aes-encryption","cryptography","network-secuirty","pycryptodome","python","python3","rsa-encryption","socket-communication"],"created_at":"2025-08-25T13:27:44.222Z","updated_at":"2025-08-25T13:27:50.162Z","avatar_url":"https://github.com/nsk89.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# netcrypt\n\n\u003cp\u003esocket transmission and encryption protocols\u003c/p\u003e\n\u003cp\u003esimplifying socket data stream cryptography using RSA public keys and AES data encryption, using PyCryptodome cryptographic primitives\u003c/p\u003e\n\n## installation\n\n\u003cp\u003eclone this repository or simply your favorite way over pip:\u003c/p\u003e\n\n```\npython3 -m pip install netcrypt\n```\n\n## how it works\n\n\u003cp\u003ethis project doesn't incorporate basic server/client functions besides communication, though that may change in the future. the current state of the project mainly deals with sending data, including files, over sockets securely. data to be sent is first encrypted using AES. the AES key and init vector are then encrypted with a RSA cipher from the public key set from the exchanging socket connection. the data(message) then creates a hash verification for use on decryption to verify data itegrity. \n\u003cbr\u003e\n\u003cbr\u003e\nkey, init vector, data verification hash and data are then stored in a dictionary to be dumped into a serialized bytes object. the serialized object is then structured into internet byte order and length of object is stored in the first four bytes of transmission. on receive, the first four bytes are read from the stream retrieving the stream length, the remainder of the stream is collected and read in based off the length. the process goes in reverse from there.\n\u003cbr\u003e\n\u003cbr\u003eall socket data encryption is done in communication.py which methods use cryptography.py(based off PyCryptodome ciphers).\n\n## getting started\n  \n\u003cp\u003ecreate a server stream encryption object, this example we'll use crypto_traffic:\u003c/p\u003e\n\n```\nfrom netcrypt.communication import ServerProtocol\n\n\ncrypto_traffic = ServerProtocol()\n```\n\u003cbr\u003e\n\n\u003cp\u003eto start encrypted communication public keys must be exchanged, exchange the public keys and store the clients key:\u003c/p\u003e\n\n```\nclient_public_key = crypto_traffic.public_key_exchange()\n```\n\u003cbr\u003e\n\n\u003cp\u003eto send or receive data, the public key needs to be set first. in this case we're sending:\u003c/p\u003e\n\n```\ncrypto_traffic.set_public_key(client_public_key)\n\nmessage = b'Welcome to the server!'\ncrypto_traffic.send_crypto_stream(conn, message) \n```\n\u003cbr\u003e\n\n\u003cp\u003eto receive the message client side:\u003c/p\u003e\n\n```\nserver_message = crypto_traffic.recv_crypto_stream(sock)\n```\n\u003cbr\u003e\n\n\u003cp\u003esending a file from server to client, in this case we have testFile.txt stored in cwd:\u003c/p\u003e\n\n```\ncrypto_traffic.send_file(conn, 'testFile.txt')\n```\n\u003cbr\u003e\n\n\u003cp\u003eto receive above file client side and store in cwd:\u003c/p\u003e\n\n```\ncrypto_traffic.recv_file(sock)\n```\n\u003cbr\u003e\n\n\u003cp\u003ea socks socket will be returned on the enable_tor() call. the returned socket object is used in place of the typical socket \u003cbr\u003eobject and inherits its functionality. route client through the tor network:\u003c/p\u003e\n\n```\ntor_sock = crypto_traffic.enable_tor()\n```\n\n\u003cbr\u003e\n\n## simple server example\n\n```\n# server byte string and file transmission example\n\nimport socket\nfrom netcrypt.communication import ServerProtocol\n\n\nhost = 'localhost'\nport = 5300\nsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\nsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\nsock.bind((host, port))\n\nsock.listen(5)  # listen on socket\nprint('**listening**')\nwhile 1:  # when connection\n    conn, addr = sock.accept()  # accept connection\n    print(f'connection! address: {addr[0]}')\n    crypto_traffic = ServerProtocol()  # server communications encryption protocol object\n    print('sending/receiving public keys')\n    client_public_key = crypto_traffic.public_key_exchange(conn)  # exchange public keys with client\n    crypto_traffic.set_public_key(client_public_key)\n    print('public keys exchanged')\n    # send welcome message to client\n    welcome_message = b'_/\\_(@_@)_/\\_\\nWelcome to the server'\n    crypto_traffic.send_crypto_stream(conn, welcome_message)\n    response = crypto_traffic.recv_crypto_stream(conn)  # receive response from client\n    print(response) \n    \n    # send file to client\n    crypto_traffic.send_file(conn, 'testFile.txt')\n    print(r'file served _/\\_(@_@)_/\\_')\n    conn.close()\n    \n```\n\n## simple client example\n\n```\n# client byte string and file receive over tor example\n\n\nimport socket\nfrom netcrypt.communication import ClientProtocol\n\n\n# create basic connection to server\nhost = 'localhost'\nport = 5300\nsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\nsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\ncrypto_traffic = ClientProtocol()  # client communications encryption protocol object\n\n# optional enable_tor(), enable connection over tor and returns tor socket object. tor must be installed\n# otherwise use above socket object \"sock\" in place of the following tor_sock\ntor_sock = crypto_traffic.enable_tor()\nprint('connecting to server')\ntor_sock.connect((host, port))\nserver_public_key = crypto_traffic.public_key_exchange(tor_sock)  # exchange public keys for encryption with server\nprint(f'received server public key:\\n{server_pubic_key}\\n')\ncrypto_traffic.set_public_key(server_public_key)\n\nserver_hello = crypto_traffic.recv_crypto_stream(tor_sock)  # receive hello from server\nprint(server_hello.decode())\ncrypto_traffic.send_crypto_stream(tor_sock, b'Thanks for having me')  # send response to server\nprint('sent response')\n\n# receive encrypted file stream from server and write to disk\ncrypto_traffic.recv_file(tor_sock)\nprint('file received and written to disk!')\n\n```\n\n# cryptographic methods\n\n## getting started\n\n\u003cp\u003ecreate an instance of CryptoProtocol:\u003c/p\u003e\n\n```\nfrom netcrypt.cryptography import CryptoProtocol\n\n\ncrypto_worker = CryptoProtocol()\n```\n\n\u003cbr\u003e\n\n\u003cp\u003egenerate random keys:\u003c/p\u003e\n\n```\naes_key = crypto_worker.generate_key(32)\ninit_vect = crypto_worker.generate_key(16)\n```\n\n\u003cbr\u003e\n\n\u003cp\u003eencrypt data with AES cipher:\u003c/p\u003e\n\n```\ndata = 'hello, world'\naes_key = crypto_worker.generate_key(32)\ninit_vect = crypto_worker.genreate_key(16)\nencrypted_data = crypto_worker.encrypt(aes_key, init_vect, data)\n```\n\n\u003cbr\u003e\n\n\u003cp\u003edecrypt data with AES cipher:\u003c/p\u003e\n\n```\ndecrypted_data = crypto_worker.decrypt(aes_key, init_vect, encrypted_data)\n```\n\n\u003cbr\u003e\n\n\u003cp\u003ecreate RSA private key and return public key:\u003c/p\u003e\n\n```\nmy_public_key = crypto_worker.start_rsa(4096)\n```\n\n\u003cbr\u003e\n\n\u003cp\u003eencrypt AES encryption key with RSA public key:\u003c/p\u003e\n\n```\nencrypted_aes_key = crypto_worker.rsa_encrypt(my_public_key, aes_key)\n```\n\n\u003cbr\u003e\n\n\u003cp\u003edecrypt AES encryption key with RSA private key:\u003c/p\u003e\n\n```\ndecrypted_aes_key = crypto_worker.rsa_decrypt(encrypted_aes_key)\n```\n\n\u003cbr\u003e\n\n## test crypto run\n\n```\nfrom netcrypt.cryptography import CryptoProtocol\n\n\n#  AES TEST\n\ndata = 'Hello there world!'  # some data to encrypt\nprint(f'starting data: {data}')\ncrypto_worker = CryptoProtocol()  # call cryptography object\n\n# generate random keys for encryption\naes_key = crypto_worker.generate_key(32)\ninit_vector = crypto_worker.generate_key(16)\n\nencrypted_data = crypto_worker.aes_encrypt(aes_key, init_vector, data)  # encrypt data\nprint(f'AES key: {aes_key}\\ninitialization vector: {init_vector}\\nencrypted data: {encrypted_data}')\n\ndecrypted_data = crypto_worker.aes_decrypt(aes_key, init_vector, encrypted_data)  # decrypt data\nprint(f'decrypted data: {decrypted_data}')\n\n\n# RSA TEST\n\ndata = 'Hello there World!'  # some data to encrypt\nprint(f'starting data: {data}')\ncrypto_worker = CryptoProtocol()  # call cryptography object\nmy_public_key = crypto_worker.start_rsa(4096)  # generate RSA private/public keys\n\n# generate random encryption keys for aes\naes_key = crypto_worker.generate_key(32)\ninit_vector = crypto_worker.generate_key(16)\n\nencrypted_data = crypto_worker.aes_encrypt(aes_key, init_vector, data)  # encrypt data with encryption keys\n\n# use RSA cipher to encrypt the encryption key and init vector used by the AES cipher\nencrypted_aes_key = crypto_worker.rsa_encrypt(my_public_key, aes_key)\nencrypted_init_vector = crypto_worker.rsa_encrypt(my_public_key, init_vector)\n# at this point encrypted key, vector and data are ready to send in a dict over a socket\nprint(f'encrypted AES key: {encrypted_aes_key}\\nencrypted initialization vector: {encrypted_init_vector}\\n'\n      f'encrypted data: {encrypted_data}')\n\n\n# use RSA private key to decrypt the encrypted AES cipher key and init vector\ndecrypted_aes_key = crypto_worker.rsa_decrypt(encrypted_aes_key)\ndecrypted_init_vector = crypto_worker.rsa_decrypt(encrypted_init_vector)\n\n# data is decrypted back into plaintext\ndecrypted_data = crypto_worker.aes_decrypt(decrypted_aes_key, decrypted_init_vector, encrypted_data)\nprint(f'decrypted data: {decrypted_data}')\n\n```\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsk89%2Fnetcrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnsk89%2Fnetcrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsk89%2Fnetcrypt/lists"}