Powershell vs console application

I have decided to make the utilities that I use in form of Powershell applications instead of Windows / Console applications

Pros:

There are simpler to use  – just run the powershell

The parsing of command line is powerfull in powershell

There are simpler to maintain ( just text scripts files)

There are no big dependencies( .NET Core/ .NET 4.x  to be installed)

This is a good tool under  my toolbelt

Everything you do in .NET you can do in Powershell ( sometimes it is much harder in .NET rather then powershell)

 

The repository is https://github.com/ignatandrei/PowershellUtils and the first item is to move the big files from C: into another drive to free space by making a junction dir ( e.g. C:\ProgramData\Package Cache and C:\Windows\Installer )

MVC 5 encrypt parameters–SEO

 

I have added SEO ( ok, a bullshit example of SEO ) to http://msprogrammer.serviciipeweb.ro/2017/03/20/mvc-5-encrypt-parameters/ .

This is pretty simple :

 public class EncDecSEOBullShit : IEncryptDecrypt
    {
        //public static string FullName = typeof(EncDecSEOBullShit).AssemblyQualifiedName;
        const string seo = "this-is-seo-";
        public string DecryptString(string value)
        {
            return value.Replace(seo, "");
        }

        public string EncryptString(string value)
        {
            return seo + value;
        }
    }

 

the action is

<a href=’@Url.ActionEnc(new EncDecSEOBullShit(), “TestEncryptSEO”, new {id=7, a = 1, b = “asd” })’>Test</a>

It generates url such as:

http://mvc5encrypt.apphb.com/Home/TestEncryptSEO/7?a=this-is-seo-1&b=this-is-seo-asd

The Action Filter to decrypt takes the full type name ( with assembly name) of the class that does SEO ( or encrypt / decrypt)

[MVCDecryptFilter(EncDecFullClassName = "MVCEncryptDemo.EncDecSEOBullShit, MVCEncryptDemo")]

Example at

http://mvc5encrypt.apphb.com/

MVC 5 encrypt parameters

 

This is an old idea that I was having. The problem was that , for many people, showing the parameters in MVC is not something that they want . For example. suppose that we have this action

 

public ActionResult TestEncrypt(int id, int a, string b)

 

The this action can be activated by putting in the Razor cshtml file this

 

<a href=’@Url.Action("TestEncrypt", new { id=7, a = 1, b = "asd" })’>Test</a>

 

that will generate this URL :

http://mvc5encrypt.apphb.com/Home/TestEncrypt/7?a=1&b=asd .

The parameters are passed in clear text ( a is 1 and b is asd). What if I want to encrypt those into the URL ,

http://mvc5encrypt.apphb.com/Home/TestEncrypt/7?a=EAAAAHT3XGpsOow%2f2Wto%2fho1C3Bmy1kTFnBosorsrt9X3Eqj&b=EAAAADbjm%2bS8NDAKqznGI%2bzF02oOAY9wf24SFyFxPxbCu0ea

 

but receive in the Action the default values ( 1 and asd)?

Enter MVC5Encrypt

What you have to do is modify slightly the code in the .cshtml and add an attribute to the Action

 

<a href=’@Url.ActionEnc("mySecret", "TestEncrypt", new { id=7, a = 1, b = "asd" })’>Test</a>

 

and the action will be

[MVCDecryptFilter(secret = &quot;mySecret&quot;)]   
public ActionResult TestEncrypt(int id, int a, string b)

 

You can see into action at

http://mvc5encrypt.apphb.com/Home/TestEncrypt/7?a=EAAAAHT3XGpsOow%2f2Wto%2fho1C3Bmy1kTFnBosorsrt9X3Eqj&b=EAAAADbjm%2bS8NDAKqznGI%2bzF02oOAY9wf24SFyFxPxbCu0ea

 

FAQ:

1.  What is “mysecret”?

See code on http://stackoverflow.com/questions/202011/encrypt-and-decrypt-a-string that I shameless copied.

 

2. What about backward compatibility ( i.e., old links will function ) ?

Yes if you do not already encode in base64 ( default class encrypter knows if the parameter value is in base64 ) . See

http://mvc5encrypt.apphb.com/Home/TestEncrypt/7?a=1&b=asd 

 

3. What about extending this with a custom encrypt class ?

You can – see this function

 

public static string ActionEnc(this UrlHelper helper, IEncryptDecrypt encDec, string actionName, object routeValues)

 

4. What about extending this to route parameters ( e.g. http://localhost/Person/Edit/5  – the 5 parameter is in the route and not encrypted ) ?

Glad you ask. Please fill an feature request on github

5. More details ? 

Sources on GitHub : https://github.com/ignatandrei/MVC5Encrypt

Demo at http://mvc5encrypt.apphb.com/ 

NuGet at https://www.nuget.org/packages/MVC5Encrypt/

( Other solution is to use http://madskristensen.net/post/httpmodule-for-query-string-encryption)

64 bit accessing 32 bit application error

 

Mixing 32 bit with 64 bit it is not allowed – see https://support.microsoft.com/en-us/kb/282423 .

However, there are several solutions to accesing 32 bit from 64 bit :

1. Simpler – create a console exe (32 bit) application that calls the library ( same bit version) . Use this from the main program.

Cons: Error handling , difficulty to debug

2. Complicated :Read this and make your solution https://blog.mattmags.com/2007/06/30/accessing-32-bit-dlls-from-64-bit-code/

3.Use a NUGET package to call 32 bit from 64 bit.

See https://github.com/CodefoundryDE/LegacyWrapper and details here: https://blog.codefoundry.de/programming/legacy-wrapper-invoking-an-unmanaged-32bit-library-out-of-a-64bit-process/

Programming Tools 2016

Those are my programming tools in 2016.  I do not put links- if you do not find them on google , please send me an email. Or comment here.

blog

Syntax Highliter
Windows live writer
WordPress

Communications

outlook
skype
Slack

Components

Angular
Asp.net mvc
Caliburn.Micro
Irony
Jquery
Jquery ui
jstree
knockoutjs
NPOI
Prism
Select 2
Selenium

Database

Elastic search
Mongodb
Sql server

NuGet

EntityFramework
ExporterWordExcelPDF
HtmlAgilityPack
iTextSharp-LGPL
MediatR
Microsoft.AspNet.WebApi.Client
nlog
NReco.VideoConverter
OneNoteOCR
structuremap
Swashbuckle.Core
T4MVC
Untiy
WebActivator
Westwind.RazorHosting
WinSCP
xunit

Presentations

powerpoint
reveal

ProgrammerUtilities

7zip
AutoHotkey
Excel
free commander
SysInternals ADSI
nugetpackage explorer
VS2015
WinMerge

RemoteUtilities

bginfo
keepass
terminals

Reporting

kibana
powerbi

ToDO Lists

coachme
Todoist
trello

VersionControl

git
mercurial
perforce