Posts

Showing posts from December, 2019

Encrypting and decrpyting using Azure KeyVault with KEY RSA

Let's say you created Azure Key Vault and created a KEY (not secret or certificate) that is made up of RSA Key. The following codes can be used to encrpyt and decrpyt value.

Powershell : creating your PEM on DevOps pipeline

Sometimes you might want to create expose your public key / generate your public key to 3rd party apps. This is a code written entirely on Powershell to help you export public key (modulus and exponent) to a legit PEM file: To use it, $pemPublicKey  = GeneratePublicKey  $your_modulus_base64encoded   $your_exponent Write-Host ( $pemPublicKey )

How C# / Netcore would like to use PEM file (Public side of things)

Publicc key are typically stored in a PEM file which contains modulus and exponent value. These get converted into RSAParameters so that it can be used by RSA to do its magic. It looks something lke this :- General Idea  var rsa = new RSACryptoServiceProvider(); rsa.ImportParameters(p); To use a nuget package called PemUtil.  This allows you to read a PEM file into a RSAParameters. Go and install a nuget package called PemUtil and then you can use the following code. Then you can plug it into code above.  public static RSAParameters ReadPEMFileB(string PemFilePath)         {             RSAParameters rsaParameters;             using (var stream = File.OpenRead(PemFilePath))             using (var reader = new PemReader(stream))             {                 rsaPar...

RSA Public Key PEM File

What is this? A PEM file which contains your public key.  Public key will contain your Modulus and Exponent. (P and Q).  It is different from private key which contains alot more information. -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxSxqCESCdpeXWCprQGMrpwlEg 91EF4Qt1R247gTGaUMgEjFEq9c/UffmtYyccmoIq3n8m/ZcsiCNJNFfGx5h/YEdR ZyzQjSLg9zt3zu5JbBNx4zb63vvhpCGoMf65y/RvMs+XjSBl8ybl0vbbrC62YH1I 7ZJYSbKhXr3ILHyUSwIDAQAB -----END PUBLIC KEY----- OpenSSL To generate a rsa key openssl genrsa -out private.pem 1024 To view your private key openssl pkey -in private.pem -text To generate a public key (your private key already contain your public key) openssl pkey -in private.pem -out public.pem -pubout View our public key (noticed the additional -pubin argument) openssl pkey -in public.pem -pubin -text

ModuleNotFoundError: No module named 'transforms.data.processors.squad'

If you encounter this issue, this is because the latest code base is not package to pypi for some reason. So i use a rather hacky way to resolve this. If you're running on your computer Clone  https://github.com/huggingface/transformers  and locate your installed python package for "transformer". It should be somewhere usr/lib/python/dist-packages. Replace all code in the dist-package transfomer folder with your clone folder. Yes, replace all as there are alot of dependencies. :( Using colab. This is almost the same, clone the repository and start upload to the destination folder. Loads of work and hope you have fun. To be honest, i didn't get it to do those hard core training. It just stall after a few runs.

OpenAI GPT2 - Generating your first content

Perhaps the best way to get started is to look at this Colab notebook. Just run it and you will see loads of fake content being generated. https://colab.research.google.com/drive/1OqF99q0-G1RCfmvcEw_qZvjuiJL_066Q#scrollTo=TsNXf-0zgaHn