Skip to main content

Posts

CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information

I created a new Blazor Server app in Visual Studio 2019 and tried to run it. But I was getting this error CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. I couldn't find any reason or solution to this problem. I tried creating the project multiple times but same error. I created a new .Net Core Web App and added a new razor component and included that component in a razor page (cshtml file) like this @(await Html.RenderComponentAsync<GeofenceWork>(RenderMode.ServerPrerendered)) and <component type="typeof(GeofenceWork)" render-mode="serverprerendered" /> As soon as I navigate to this page that has component added I got the same error: CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. This was very frustrating. After hours of trying and searching I figured out the solution. 
Recent posts

Freelancer.com has turned into a scam site

How I got scammed 3 times by Freelancer.com Freelancer.com , the most popular platform for freelancing has now turned into a scam machine. I am not talking about employers/freelancers running away but instead the staff of freelancer.com is involved.  I have recently lost $600 and I will explain how (the points I will mention below has happened to me 3 times in last 1 year): Project awarded -> milestones paid (lets say $300) -> everything good I withdraw my money after few days Suddenly in the morning I see that $300 are locked from my account mentioning security reasons I contact freelancer.com support they say that employer you worked for has some problem in their account verification and we have asked them to verify so your amount will be unlocked once they are verified I wait 3–4 days. No updates. My employer mentioned that they have submitted the required information and support has given them 48 hours to resolve the issue. I contact support again and they say that your emp

Protecting APIs against Replay Attack

Replay attacks are very popular against public APIs.  What is a replay attack ? When an attacker intercepts a valid HTTP request to your API and then replay the same request again and again tricking your API into thinking that it is a valid HTTP request coming from your user. Protection Here is a very simple method that I use to protect my APIs from Replay Attacks . Client side steps 1. Generate a unique token on server for the device when app is used for the first time or if app requires login then generate token on successful login. 2. Whenever app makes a call to server it adds the following in HTTP headers Token 128 characters long random value (call it Random1 ) Current Unix Timestamp of device SHA256 of "Token+|||+Random1+|||+Timestamp" (call this result Random2 ) Server side steps When a HTTP request is received by any API it takes the following steps to verify the validity of request Check if Token is a valid token that exists in database (you can implement expiry mec

Failed to resolve: com.android.support:cardview-v7:26.0.0 android and similar

Recently I updated my android SDK tools and I started getting this error Failed to resolve: com.android.support:cardview-v7:26.0.0 android Solution to this or any other similar error is to add maven end point in your build.gradle file allprojects {     repositories {         jcenter()         maven {             url 'https://maven.google.com'         }     } } 

Ionic2 Error Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper

Recently I upgraded to latest version of ionic and started getting following error when building app for android Error: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio To solve this issue you have to perform following steps Download Gradle from https://gradle.org/install/#manually Extract the downloaded zip file somewhere (e.g. D:\gradle) Add "D:\gradle\bin" to Path in your Environment variables After performing these steps everything started working fine for me. Hope you find this helpful :)

Encoding raw images to Ogg Theora video using libavcodec

In one of the blog posts we learned how to decode jpeg images using libavcodec. This is the second part of that post. In this we will learn how to encode decoded images (raw images) to theora and write them in ogg video file. In the end of the first part we saved our raw image in raw_data variable and its length in raw_data_size variable. Lets assume that we packaged all our decoding code in one function called "decode_jpeg_image" which has following signature int decode_jpeg_image(char *filename,int file_name_size,uint8_t *raw_data,int *raw_data_size) filename = name of jpeg file to decode file_name_size = length of jpeg file's name raw_data = contains decoded raw image on return raw_data_size = contains length of raw_data on return Now let's start working on how to encode this image in raw_data to theora and write that image to ogg video file. Finding Theora encoder We first have to find encoder for THEORA which is represented by AVCodec structure. He

Ionic1 scrolling bounce effect not working in android

I faced a weird problem in my recent ionic1 app. App is a social network that shows news feed. When I tested in browsers scrolling was smooth and when end of list is reached ionic's bouncing effect shows up. But running the app in android do not show any bouncy effects instead its just a "hard scrolling". After reading the docs I realized that bouncy effect is disabled in android by default so i have to add has-bouncing="true" in ion-content . So I added it <ion-content class="has-header" has-bouncing="true"> But still I didn't  get bouncy effect on end of scroll. It was same "hard scrolling" that just stops when end of list is reached without showing any effect. To solve this issue we have to add overflow-scrolling="false" in our ion-content along with has-bouncing="true" <ion-content class="has-header" overflow-scroll="false" has-bouncing="true">