c# - MachineKey.Encode output is hex how do i set it do base64? -


i'm trying match viewstate encryption in code, issue output of machinekey.encode hex encoded , not base64 encoded. code is:

        var plaintextbytes = encoding.utf8.getbytes("hello");         var encryptedvalue = machinekey.encode(plaintextbytes, machinekeyprotection.all);         encrypteddata.text = encryptedvalue;          var decryptedbytes = machinekey.decode(encryptedvalue, machinekeyprotection.all);         decrypteddata.text = encoding.utf8.getstring(decryptedbytes); 

do have idea how can make code output base64 encoded string viewstate data encrypted?

first off, consider using machinekey.protect , .unprotect, encode , decode obsolete.

protect returns byte[], can pass convert.tobase64string

 byte[] encryptedvalue = machinekey.protect(encoding.utf8.getbytes("hello"), "some reason or another");  string encryptedutf8 = convert.tobase64string(encryptedvalue); 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -