Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cryptoblocks64

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cryptoblocks64

A collection of common cryptography related functions but in B64 operation format

  • 0.0.4
  • PyPI
  • Socket score

Maintainers
1

Crypto Blocks is a simple package that consists of various fundamental functions for building cryptogaphic algorithms.

To Install

Just use pip install cryptoblocks64 to install.

It provides:

  • Various general functions required for creating your own Cryptographic algorithm.
  • Functions are Classified into classes for ease of use.
  • instead of operating on a single bit this edition works in B64 style (instead of {0 or 1} its {0,....,63} values per element)
  • Provides easy encoding conversion,S&P Box generation,and many more functions

The Structure:

There are total 4 main classes which are:

  • Convert
  • Padding
  • Process
  • Generate

Convert:

consists of various datatype and encoding conversion functions

functiondescriptioncode example
string_to_b64converts input string to URL-Safe Base64 encoded string.encoded_string = cb.convert.string_to_b64(string1)
b64_to_stringconverts only Base64 encoded string back UTF-8 encoded string.original_string = cb.convert.b64_to_string(encoded_string)
string_to_arrayconverts base64 string to int array with value range 0-63.array = cb.convert.string_to_array(encoded_string)
array_to_stringconverts int array with value range 0-63 back to UTF-8 string.encoded_string = cb.convert.string_to_array(array)

Padding:

consists of array padding and removing function. works in PKCS style.

functiondescriptioncode example
padpadd's the array in PKCS standard to lenght specified by user.array_with_padding = cb.padding.pad(array_without_padding,block_size)
pad_REMOVEremoves the padding from the array.array_without_padding = cb.padding.pad_REMOVE(array_with_padding)

Process:

consists of general cryptography related math functions.

functiondescriptioncode example
XOR_arrayperforms XOR between two arrays of same length.XOR_of_arrays = cb.process.XOR_array(array1,array2)
ADD_arrayperforms ADD between (array1,array2) of same lengh with (mod 64).ADD_of_arrays = cb.process.ADD_array(array1,array2)
shiftperforms shift operation on array in left or right direction by specified amount.shifted_array = cb.process.shift(array1,shiftamount,direction)
s_boxperforms substititution on the array with reference from sbox array.substituted_array = cb.process.s_box(array1,s_box)
s_box_inverseperforms inverse substititution on the array with reference from sbox array.Used in decryptioninverse_substituted_array = cb.process.s_box_inverse(array1,s_box)
p_boxperforms permutation on the array with reference from pbox array.permutated_array = cb.process.p_box(array1,p_box)
p_box_inverseperforms inverse permutation on the array with reference from pbox array.Used in decryptioninverse_permutated_array = cb.process.p_box_inverse(array1,p_box)
swap_halfswaps the two half in the array (use shift if you want to swap at custom position).swapped_array = cb.process.swap_half(array1)

Gnerate:

consists of tools to generate string,arrays and S&P Box generators with cryptographically secure methods.

functiondescriptioncode example
box_generategenerates an array of size mentioned with elements from {0,size-1} in random order and also returns its inverse.s_box,inv_s_box=cb.generate.box_generate(boxsize)
string_generategenerates a string of mentiond size with random base64 charactersrandom_string=cb.generate.string_generate(stringsize)
array_generategenerates a numpy array of lenght (size) with value between {0,63}.random_array=cb.generate.array_generate(arraysize)

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc