Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Specified cast is not valid Pin
Gerry Schmitz23-Dec-16 6:50
mveGerry Schmitz23-Dec-16 6:50 
GeneralRe: C# Specified cast is not valid Pin
Richard MacCutchan23-Dec-16 6:59
mveRichard MacCutchan23-Dec-16 6:59 
QuestionWhat is this JWT Code Doing? Pin
TheOnlyRealTodd21-Dec-16 15:46
professionalTheOnlyRealTodd21-Dec-16 15:46 
GeneralRe: What is this JWT Code Doing? Pin
Richard MacCutchan21-Dec-16 21:54
mveRichard MacCutchan21-Dec-16 21:54 
GeneralRe: What is this JWT Code Doing? Pin
TheOnlyRealTodd21-Dec-16 22:35
professionalTheOnlyRealTodd21-Dec-16 22:35 
GeneralRe: What is this JWT Code Doing? Pin
OriginalGriff21-Dec-16 23:24
mveOriginalGriff21-Dec-16 23:24 
GeneralRe: What is this JWT Code Doing? Pin
Gerry Schmitz22-Dec-16 4:07
mveGerry Schmitz22-Dec-16 4:07 
AnswerRe: What is this JWT Code Doing? Pin
Richard Deeming22-Dec-16 2:35
mveRichard Deeming22-Dec-16 2:35 
TheOnlyRealTodd wrote:
3. It decodes the AudienceSecret from Base64Url into a byte array? <----This is where I'm confused. The secret is just a URL???

The secret is a Base64[^]-encoded byte array.

The TextEncodings.Base64Url.Decode method uses Convert.FromBase64String[^]. It replaces some characters that can't be used in a URL, and pads the string to the correct length.

It's not clear why you'd need to do that, since you're not passing the string in a URL.
C#
public class Base64UrlTextEncoder : ITextEncoder
{
    public string Encode(byte[] data)
    {
        if (data == null) throw new ArgumentNullException("data");
        return Convert.ToBase64String(data).TrimEnd('=').Replace('+', '-').Replace('/', '_');
    }

    public byte[] Decode(string text)
    {
        if (text == null) throw new ArgumentNullException("text");
        return Convert.FromBase64String(Pad(text.Replace('-', '+').Replace('_', '/')));
    }

    private static string Pad(string text)
    {
        int count = 3 - (text.Length + 3) % 4;
        if (count == 0) return text;
        return text + new string('=', count);
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


QuestionNeed help on how to if record exists update else insert c# Pin
Bootzilla3321-Dec-16 7:56
Bootzilla3321-Dec-16 7:56 
AnswerRe: Need help on how to if record exists update else insert c# Pin
Michael_Davies21-Dec-16 8:04
Michael_Davies21-Dec-16 8:04 
AnswerRe: Need help on how to if record exists update else insert c# Pin
Richard Deeming21-Dec-16 8:06
mveRichard Deeming21-Dec-16 8:06 
AnswerRe: Need help on how to if record exists update else insert c# Pin
Nelson Costa Inácio21-Dec-16 23:34
Nelson Costa Inácio21-Dec-16 23:34 
QuestionC# PictureBox remove image Pin
Pavlex420-Dec-16 11:21
Pavlex420-Dec-16 11:21 
AnswerRe: C# PictureBox remove image Pin
Pavlex420-Dec-16 11:39
Pavlex420-Dec-16 11:39 
GeneralRe: C# PictureBox remove image Pin
Mohan Baro20-Dec-16 18:10
Mohan Baro20-Dec-16 18:10 
GeneralRe: C# PictureBox remove image Pin
Pavlex420-Dec-16 20:11
Pavlex420-Dec-16 20:11 
SuggestionRe: C# PictureBox remove image Pin
Ralf Meier20-Dec-16 21:19
mveRalf Meier20-Dec-16 21:19 
GeneralRe: C# PictureBox remove image Pin
Pavlex420-Dec-16 21:24
Pavlex420-Dec-16 21:24 
GeneralRe: C# PictureBox remove image Pin
Ralf Meier21-Dec-16 1:18
mveRalf Meier21-Dec-16 1:18 
GeneralRe: C# PictureBox remove image Pin
Pavlex421-Dec-16 8:21
Pavlex421-Dec-16 8:21 
GeneralRe: C# PictureBox remove image Pin
Ralf Meier21-Dec-16 22:58
mveRalf Meier21-Dec-16 22:58 
QuestionSpecified cast is not valid. i can't understand error Pin
Member 1289974620-Dec-16 2:07
Member 1289974620-Dec-16 2:07 
AnswerRe: Specified cast is not valid. i can't understand error Pin
OriginalGriff20-Dec-16 2:30
mveOriginalGriff20-Dec-16 2:30 
GeneralRe: Specified cast is not valid. i can't understand error Pin
Member 1289974620-Dec-16 2:34
Member 1289974620-Dec-16 2:34 
GeneralRe: Specified cast is not valid. i can't understand error Pin
Ralf Meier20-Dec-16 2:38
mveRalf Meier20-Dec-16 2:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.