Package: xstrip-auth
xstrip-authCryptographically strong pseudorandom key generator based on the XStrip AlgorithmInstallingViaPyPI:pipinstallxstrip_authUsageGenerate a 256-bit key for usefromxstrip_authimportXStripKeyConstructkey="#P@$$W0R9"construct=XStripKeyConstruct(key)# Creating a 16Bit key for use from the key under a md5 hash implementationconstruct.generateKey(hf='md5')# Prints#   [md5](16): 'ec1a93e0f8d41d75ffb77914e7a31cbf'# Create a 256bit key for use from the key under the sha256 hash implementationconstruct.generateKey(hf='sha256')# Prints#   [sha256](32): 'd6b05d17e2e15152c478825ca6e7adafd0045b0c7fd92850ead98bad0cced9a4'APIClass:XStripKey(hash, salt[, iterations][, hf])hash: <bytes> The key, final content to be encapsulated by the instancesalt: <bytes> The salt used to intensify the operationiterations: <number> Number of iterations undergone to generate thehash. Default:100000hf: <string> Hash function used for the operation. Default:'sha256'Encapsulate a generated key within an interfacing instance for managing the inherent contentTheXStripKeyclass is defined and exposed publicly by the module:fromxstrip_authimportXStripKeykey=XStripKey(bytes.fromhex('d4d64d71c71ed5365ddde126ca8e6a17301e5f9601a15119e53c2f91def21f11'),bytes.fromhex('422f487975c57bb648f3'))print(key.verify("#P@$$W0R9"))# Prints#   TrueXStripKey::hex(getter)Shows the encapsulated key in byte hex formatXStripKey::hf(getter)Returns the hash function of the keyXStripKey::salt(getter)Returns the salt of the key in bytesXStripKey::iterations(getter)Returns the number of iterations used in encoding the keyXStripKey::verify(key[, encoder])key: <string>encoder: <function>Returns: <boolean>Verify whether or not the specifiedkeymatches the inherent key of theselfinstanceencoderis defined by any transformers that was used used in generating the construct else, this falls back to anoopfunction that returns its parameters
Returns a boolean for the condition resultXStripKey::matchExec(key, fn[, *args][, encoder])key: <string>fn: <function>*args: <any>encoder: <function>Returns: <any>Execute thefnfunction if thekeymatches the inherent key of theselfinstance by checkingself.verify(key,encoder)
fn is called by arguments defined inargs(if-any)encoderis defined by any transformers that was used used in generating the construct else, this falls back to anoopfunction that returns its parameters
Returns the return content of the functionfndeffn(value):print("Password Matches, arg:%d"%value)key.matchExec("#P@$$W0R9",fn,10)# Prints#   Password Matches, arg: 10XStripKey::mismatchExec(key, fn[, *args][, encoder])key: <string>fn: <function>*args: <any>encoder: <function>Returns: <any>Execute thefnfunction if thekeydoes not match the inherent key of theselfinstance by checkingself.verify(key,encoder)
fn is called by arguments defined inargs(if-any)encoderis defined by any transformers that was used used in generating the construct else, this falls back to anoopfunction that returns its parameters
Returns the return content of the functionfndeffn(value):print("Password Matches, arg:%d"%value)key.mismatchExec("something",fn,19)# Prints#   Password Matches, arg: 19XStripKey::codes()Returns the octal representation of each character in a listXStripKey::export()Exports the entire key construct in base64 encoding parsable byXStripKey.parse()print(key.export())# Prints#   b'MTAwMDAwOjQyMmY0ODc5NzVjNTdiYjY0OGYzL2Q0Z...OGU2YTE3MzAxZTVmOTYwMWExNTExOWU1M2MyZjkxZGVmMjFmMTE='XStripKey.parse(content)fn: <string | bytes> The exported construct to be parsed
Returns: <XStripKey>Parse the base64 exported data fromXStripKey::exportprint(XStripKey.parse(key.export()))print(key==XStripKey.parse(key.export()))# Prints#   [sha256](32): 'd4d64d71c71ed5365ddde126ca8e6a17301e5f9601a15119e53c2f91def21f11'#   TrueClass:XStripKeyConstruct(key[, iterations])key: <string | bytes> The key to be constructed oniterations: <number> The number of times the kdf should apply the hash function to the key in the transformative processClass to generate series of hashed keys for a single key
Making the product pseudorandomly secure for every use of the same keyTheXStripKeyclass is defined and exposed publicly by the module:fromxstrip_authimportXStripKeyConstructXStripKey::generateKey([hf][, salt][, encoder])hf: <string> The hash function to process the key on. Default:'sha256'salt: <string | bytes> The hash to be used on the key when randomising the data. Default:py:os/randomencoder: <function> The middleware transformative function. Default:noopReturns: <XStripKey>Generates a special key for the encapsulated key under special conditions making the product completely random and untied to the operation
Hence, generating cryptographically secure keys everytime this method is calledencoderis defined by any transformers that was used used in generating the construct else, this falls back to anoopfunction that returns its parametersconstruct=XStripKeyConstruct("t0y$t0ry")construct.generateKey()# [sha256](32): '5e53edcff3bc4dc5e06b243dd206e4dbba1be625361bd2db3c9599edec217f01'construct.generateKey()# [sha256](32): '907d183f27a75c23830906063494ff073942e3f74d21605f7b19b16a7d94df06'construct.generateKey('md5')# [md5](16): 'd38518dccec4a4ef1767c01e48095a2c'construct.generateKey('sha1')# [sha1](20): '42f405740cd7a35a283b44c1ee0bbf0c9812015b'DevelopmentBuildingFeel free to clone, use in adherance to thelicenseand perhaps send pull requestsgitclonehttps://github.com/miraclx/xstrip-auth.gitcdxstrip-auth# hack on codepip3install.--userLicenseApache 2.0©Miraculous Owonubi(@miraclx) <omiraculous@gmail.com>