Posts

Showing posts from 2020

Couchbase Golang "failed to get query provider: not connected to cluster | {"statement":"*"}"

Image
Go (also known as Golang) is an open source programming language developed by Google Couchbase is a NoSQL database built for business-critical applications. While using Golang sdk 2.0 for Couchbase, I encountered an error "failed to get query provider: not connected to cluster | {"statement":"*"}" But this error had a strange behaviour, whenever I run any insert or update operation via Sdk function prior running  Cluster. Query (query, &gocb.QueryOptions{NamedParameters: params})  this error didn't occurred.  Running Just  Cluster. Query (query, &gocb.QueryOptions{NamedParameters: params})  after connection directly would get  "failed to get query provider: not connected to cluster | {"statement":"*"}" What I did to  tackle this is, prior to the Query function or immediately after running the connect function I ran a atomic function  collection. Binary (). Increment ( "serverUp"

RSA encryption in python 🐍

Image
RSA Encryption in Python 3.8 First install the dependencies ie pycryptodome library [pycryptodome 3.9.7]: pip3 install pycryptodome from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP import binascii keyPair = RSA.generate(3072) pubKey = keyPair.publickey() pubKey = pubKey.exportKey() pubKey = pubKey.decode('utf-8') privKey = keyPair.exportKey() privKey = privKey.decode('utf-8') key = RSA.importKey(pubKey) msg = b'A message for encryption' encryptor = PKCS1_OAEP.new(key) encrypted = encryptor.encrypt(msg) encrypted = binascii.hexlify(encrypted) encrypted = encrypted.decode('utf-8') print(encrypted) key = RSA.importKey(privKey) decryptor = PKCS1_OAEP.new(key) encrypted = encrypted.encode('utf-8') encrypted = binascii.unhexlify(encrypted) decrypted = decryptor.decrypt(encrypted) decrypted = decrypted.decode('utf-8') print('Decrypted:', decrypted)